Changeset: 8fb1d84605c2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8fb1d84605c2 Modified Files: monetdb5/modules/mal/remote.c sql/backends/monet5/sql.c sql/backends/monet5/sql_rank.c sql/backends/monet5/sql_scenario.c Branch: default Log Message:
Merge with Jul2021 branch. diffs (truncated from 768 to 300 lines): diff --git a/gdk/ChangeLog.Jul2021 b/gdk/ChangeLog.Jul2021 --- a/gdk/ChangeLog.Jul2021 +++ b/gdk/ChangeLog.Jul2021 @@ -1,3 +1,8 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Fri Jul 30 2021 Sjoerd Mullender <sjo...@acm.org> +- Hash indexes are no longer maintained at all cost: if the number of + distinct values is too small compared to the total number of values, + the index is dropped instead of being maintained during updates. + diff --git a/monetdb5/modules/kernel/aggr.c b/monetdb5/modules/kernel/aggr.c --- a/monetdb5/modules/kernel/aggr.c +++ b/monetdb5/modules/kernel/aggr.c @@ -35,7 +35,7 @@ AGGRgrouped(bat *retval1, bat *retval2, b = BATdescriptor(*bid); g = gid ? BATdescriptor(*gid) : NULL; - e = eid ? BBPquickdesc(*eid) : NULL; + e = eid ? BATdescriptor(*eid) : NULL; s = sid ? BATdescriptor(*sid) : NULL; q = quantile ? BATdescriptor(*quantile) : NULL; @@ -48,6 +48,8 @@ AGGRgrouped(bat *retval1, bat *retval2, BBPunfix(b->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); if (q) @@ -76,6 +78,8 @@ AGGRgrouped(bat *retval1, bat *retval2, BBPunfix(b->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); BBPunfix(q->batCacheid); @@ -93,6 +97,8 @@ AGGRgrouped(bat *retval1, bat *retval2, BBPunfix(b->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); if (bn == NULL) @@ -620,7 +626,7 @@ AGGRavg3(bat *retval1, bat *retval2, bat b = BATdescriptor(*bid); g = gid != NULL && !is_bat_nil(*gid) ? BATdescriptor(*gid) : NULL; - e = eid != NULL && !is_bat_nil(*eid) ? BBPquickdesc(*eid) : NULL; + e = eid != NULL && !is_bat_nil(*eid) ? BATdescriptor(*eid) : NULL; s = sid != NULL && !is_bat_nil(*sid) ? BATdescriptor(*sid) : NULL; if (b == NULL || @@ -631,6 +637,8 @@ AGGRavg3(bat *retval1, bat *retval2, bat BBPunfix(b->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); throw(MAL, "aggr.subavg", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); @@ -641,6 +649,8 @@ AGGRavg3(bat *retval1, bat *retval2, bat BBPunfix(b->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); if (rc != GDK_SUCCEED) @@ -663,7 +673,7 @@ AGGRavg3comb(bat *retval1, const bat *bi r = BATdescriptor(*rid); c = BATdescriptor(*cid); g = gid != NULL && !is_bat_nil(*gid) ? BATdescriptor(*gid) : NULL; - e = eid != NULL && !is_bat_nil(*eid) ? BBPquickdesc(*eid) : NULL; + e = eid != NULL && !is_bat_nil(*eid) ? BATdescriptor(*eid) : NULL; if (b == NULL || r == NULL || @@ -678,6 +688,8 @@ AGGRavg3comb(bat *retval1, const bat *bi BBPunfix(c->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); throw(MAL, "aggr.subavg", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); } @@ -688,6 +700,8 @@ AGGRavg3comb(bat *retval1, const bat *bi BBPunfix(c->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (bn == NULL) throw(MAL, "aggr.subavg", GDK_EXCEPTION); *retval1 = bn->batCacheid; @@ -987,7 +1001,7 @@ AGGRgroup_str_concat(bat *retval1, const b = BATdescriptor(*bid); g = gid ? BATdescriptor(*gid) : NULL; - e = eid ? BBPquickdesc(*eid) : NULL; + e = eid ? BATdescriptor(*eid) : NULL; s = sid ? BATdescriptor(*sid) : NULL; sep = sepid ? BATdescriptor(*sepid) : NULL; @@ -997,6 +1011,8 @@ AGGRgroup_str_concat(bat *retval1, const BBPunfix(b->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); if (sep) @@ -1009,6 +1025,8 @@ AGGRgroup_str_concat(bat *retval1, const BBPunfix(b->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); if (sep) @@ -1070,7 +1088,7 @@ AGGRgrouped2(bat *retval, const bat *bid b1 = BATdescriptor(*bid1); b2 = BATdescriptor(*bid2); g = gid ? BATdescriptor(*gid) : NULL; - e = eid ? BBPquickdesc(*eid) : NULL; + e = eid ? BATdescriptor(*eid) : NULL; s = sid ? BATdescriptor(*sid) : NULL; if (b1 == NULL || b2 == NULL || (gid != NULL && g == NULL) || (eid != NULL && e == NULL) || @@ -1081,6 +1099,8 @@ AGGRgrouped2(bat *retval, const bat *bid BBPunfix(b2->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); @@ -1091,6 +1111,8 @@ AGGRgrouped2(bat *retval, const bat *bid BBPunfix(b2->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); throw(MAL, malfunc, SQLSTATE(42000) "%s requires both arguments of the same type", malfunc); @@ -1102,6 +1124,8 @@ AGGRgrouped2(bat *retval, const bat *bid BBPunfix(b2->batCacheid); if (g) BBPunfix(g->batCacheid); + if (e) + BBPunfix(e->batCacheid); if (s) BBPunfix(s->batCacheid); if (bn == NULL) 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 @@ -793,19 +793,28 @@ ALGcrossproduct(bat *l, bat *r, const ba BAT *sl = NULL, *sr = NULL; gdk_return ret; - if ((L = BBPquickdesc(*left)) == NULL) - throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); - if ((R = BBPquickdesc(*right)) == NULL) + if ((L = BATdescriptor(*left)) == NULL || + (R = BATdescriptor(*right)) == NULL) { + if (L) + BBPunfix(L->batCacheid); + if (R) + BBPunfix(R->batCacheid); throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); - if (slid && !is_bat_nil(*slid) && (sl = BATdescriptor(*slid)) == NULL) - throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); - if (srid && !is_bat_nil(*srid) && (sr = BATdescriptor(*srid)) == NULL) { + } + if ((slid && !is_bat_nil(*slid) && (sl = BATdescriptor(*slid)) == NULL) || + (srid && !is_bat_nil(*srid) && (sr = BATdescriptor(*srid)) == NULL)) { + BBPunfix(L->batCacheid); + BBPunfix(R->batCacheid); if (sl) BBPunfix(sl->batCacheid); + if (sr) + BBPunfix(sr->batCacheid); throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); } ret = BATsubcross(&bn1, r ? &bn2 : NULL, L, R, sl, sr, max_one && !is_bit_nil(*max_one) && *max_one); + BBPunfix(L->batCacheid); + BBPunfix(R->batCacheid); if (sl) BBPunfix(sl->batCacheid); if (sr) @@ -971,46 +980,28 @@ ALGsort11(bat *result, const bat *bid, c static str ALGcountCND_nil(lng *result, const bat *bid, const bat *cnd, const bit *ignore_nils) { - str msg = MAL_SUCCEED; - BAT *b = NULL, *s = NULL; - bool heap_loaded = false; + BAT *b, *s = NULL; - if (!(b = BBPquickdesc(*bid))) { - msg = createException(MAL, "aggr.count", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); - goto bailout; + if ((b = BATdescriptor(*bid)) == NULL) { + throw(MAL, "aggr.count", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); } - if (cnd && !is_bat_nil(*cnd) && !(s = BATdescriptor(*cnd))) { - msg = createException(MAL, "aggr.count", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); - goto bailout; - } - if (b->ttype == TYPE_void || b->ttype == TYPE_msk || (*ignore_nils && !b->tnonil)) { - if (!(b = BATdescriptor(*bid))) { /* has to load the heap */ - msg = createException(MAL, "aggr.count", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); - goto bailout; - } - heap_loaded = true; + if (cnd && !is_bat_nil(*cnd) && (s = BATdescriptor(*cnd)) == NULL) { + BBPunfix(b->batCacheid); + throw(MAL, "aggr.count", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); } - if (b->ttype == TYPE_msk || mask_cand(b)) { - assert(heap_loaded); - if (BATsum(result, TYPE_lng, b, s, *ignore_nils, false, false) != GDK_SUCCEED) { - msg = createException(MAL, "aggr.count", GDK_EXCEPTION); - goto bailout; - } - } else if (*ignore_nils && !b->tnonil) { - assert(heap_loaded); - *result = (lng) BATcount_no_nil(b, s); - } else { - struct canditer ci; - *result = (lng) canditer_init(&ci, b, s); - } - -bailout: - if (b && heap_loaded) - BBPunfix(b->batCacheid); + BATsum(result, TYPE_lng, b, s, *ignore_nils, false, false); + } else + if (*ignore_nils) { + *result = (lng) BATcount_no_nil(b, s); + } else { + struct canditer ci; + *result = (lng) canditer_init(&ci, b, s); + } if (s) BBPunfix(s->batCacheid); - return msg; + BBPunfix(b->batCacheid); + return MAL_SUCCEED; } static str diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c --- a/monetdb5/modules/mal/remote.c +++ b/monetdb5/modules/mal/remote.c @@ -1516,8 +1516,12 @@ static str RMTbincopyto(Client cntxt, Ma throw(MAL, "remote.bincopyto", MAL_MALLOC_FAIL); sendtheap = b->ttype != TYPE_void && b->tvarsized; - if (isVIEW(b) && sendtheap && VIEWvtparent(b) && BATcount(b) < BATcount(BBP_cache(VIEWvtparent(b)))) + if (isVIEW(b) && sendtheap && VIEWvtparent(b) && BATcount(b) < BATcount(BBP_cache(VIEWvtparent(b)))) { + if ((b = BATdescriptor(bid)) == NULL) + throw(MAL, "remote.bincopyto", RUNTIME_OBJECT_MISSING); v = COLcopy(b, b->ttype, true, TRANSIENT); + BBPunfix(b->batCacheid); + } mnstr_printf(cntxt->fdout, /*JSON*/"{" "\"version\":1," diff --git a/monetdb5/optimizer/opt_wlc.c b/monetdb5/optimizer/opt_wlc.c --- a/monetdb5/optimizer/opt_wlc.c +++ b/monetdb5/optimizer/opt_wlc.c @@ -118,7 +118,7 @@ OPTwlcImplementation(Client cntxt, MalBl getFunctionId(p) == claimRef || getFunctionId(p) == deleteRef || getFunctionId(p) == clear_tableRef ) && - strcmp( getVarConstant(mb,getArg(p,2)).val.sval, "tmp") != 0 ){ + strcmp( getVarConstant(mb,getArg(p,2+(getFunctionId(p) == claimRef))).val.sval, "tmp") != 0 ){ assert( def);// should always be there, temporary tables are always ignored setFunctionId(def,actionRef); if((q= copyInstruction(p)) == NULL) { diff --git a/sql/ChangeLog.Jul2021 b/sql/ChangeLog.Jul2021 --- a/sql/ChangeLog.Jul2021 _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list