Changeset: 1ef467e6d092 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1ef467e6d092 Modified Files: gdk/gdk_group.c sql/backends/monet5/for.c sql/server/rel_optimizer.c Branch: pushcands Log Message:
Merged with default diffs (265 lines): diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c --- a/gdk/gdk_group.c +++ b/gdk/gdk_group.c @@ -611,7 +611,7 @@ ctz(oid x) if (ci.tpe == cand_dense) { \ TIMEOUT_LOOP_IDX(r, cnt, timeoffset) { \ oid o = canditer_next_dense(&ci); \ - p = o - b->hseqbase; \ + p = o - hseqb; \ uint##BG##_t x = GV; \ if ((v = sgrps[x]) == (uint##BG##_t) ~0 && ngrp < (1 << BG)) { \ sgrps[x] = v = (uint##BG##_t) ngrp++; \ @@ -628,7 +628,7 @@ ctz(oid x) } else { \ TIMEOUT_LOOP_IDX(r, cnt, timeoffset) { \ oid o = canditer_next(&ci); \ - p = o - b->hseqbase; \ + p = o - hseqb; \ uint##BG##_t x = GV; \ if ((v = sgrps[x]) == (uint##BG##_t) ~0 && ngrp < (1 << BG)) { \ sgrps[x] = v = (uint##BG##_t) ngrp++; \ diff --git a/monetdb5/optimizer/opt_dict.c b/monetdb5/optimizer/opt_dict.c --- a/monetdb5/optimizer/opt_dict.c +++ b/monetdb5/optimizer/opt_dict.c @@ -71,6 +71,7 @@ OPTdictImplementation(Client cntxt, MalB varisdict[k] = getArg(p,1); vardictvalue[k] = getArg(p, 2); dictunique[k] = 1; + freeInstruction(p); continue; } int done = 0; @@ -90,6 +91,7 @@ OPTdictImplementation(Client cntxt, MalB vardictvalue[l] = vardictvalue[k]; dictunique[l] = dictunique[k]; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else if (p->argc == 2 && p->retc == 1 && getFunctionId(p) == NULL) { @@ -98,6 +100,7 @@ OPTdictImplementation(Client cntxt, MalB varisdict[l] = varisdict[k]; vardictvalue[l] = vardictvalue[k]; dictunique[l] = dictunique[k]; + freeInstruction(p); done = 1; break; } else if (getModuleId(p) == algebraRef && getFunctionId(p) == subsliceRef) { @@ -106,6 +109,7 @@ OPTdictImplementation(Client cntxt, MalB InstrPtr r = copyInstruction(p); getArg(r, j) = varisdict[k]; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else if (getModuleId(p) == batRef && getFunctionId(p) == mirrorRef) { @@ -114,6 +118,7 @@ OPTdictImplementation(Client cntxt, MalB InstrPtr r = copyInstruction(p); getArg(r, j) = varisdict[k]; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else if (isSelect(p)) { @@ -173,6 +178,7 @@ OPTdictImplementation(Client cntxt, MalB t = pushNil(mb, t, TYPE_lng); /* estimate */ pushInstruction(mb,t); } + freeInstruction(p); done = 1; break; } else if (j == 2 && p->argc > j+1 && getModuleId(p) == algebraRef && getFunctionId(p) == joinRef @@ -186,6 +192,7 @@ OPTdictImplementation(Client cntxt, MalB getArg(r, j+0) = varisdict[k]; getArg(r, j+1) = varisdict[l]; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else if (j == 2 && p->argc > j+1 && getModuleId(p) == algebraRef && getFunctionId(p) == joinRef @@ -207,6 +214,7 @@ OPTdictImplementation(Client cntxt, MalB r = addArgument(mb, r, getArg(p, 6)); r = addArgument(mb, r, getArg(p, 7)); pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else if ((isMapOp(p) || isMap2Op(p)) && allConstExcept(mb, p, j)) { @@ -224,6 +232,7 @@ OPTdictImplementation(Client cntxt, MalB vardictvalue[l] = vardictvalue[m] = getArg(r,0); dictunique[l] = 0; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else if (getModuleId(p) == groupRef && @@ -256,6 +265,7 @@ OPTdictImplementation(Client cntxt, MalB InstrPtr r = copyInstruction(p); getArg(r, j) = input; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else { @@ -280,7 +290,7 @@ OPTdictImplementation(Client cntxt, MalB for(; i<slimit; i++) if (old[i]) - pushInstruction(mb, old[i]); + freeInstruction(old[i]); /* Defense line against incorrect plans */ if (actions > 0){ msg = chkTypes(cntxt->usermodule, mb, FALSE); diff --git a/monetdb5/optimizer/opt_for.c b/monetdb5/optimizer/opt_for.c --- a/monetdb5/optimizer/opt_for.c +++ b/monetdb5/optimizer/opt_for.c @@ -69,6 +69,7 @@ OPTforImplementation(Client cntxt, MalBl k = getArg(p,0); varisfor[k] = getArg(p,1); varforvalue[k] = getArg(p, 2); + freeInstruction(p); continue; } int done = 0; @@ -87,6 +88,7 @@ OPTforImplementation(Client cntxt, MalBl varisfor[l] = getArg(r,0); varforvalue[l] = varforvalue[k]; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else if (p->argc == 2 && p->retc == 1 && getFunctionId(p) == NULL) { @@ -94,6 +96,7 @@ OPTforImplementation(Client cntxt, MalBl int l = getArg(p, 0); varisfor[l] = varisfor[k]; varforvalue[l] = varforvalue[k]; + freeInstruction(p); done = 1; break; } else if (getModuleId(p) == algebraRef && getFunctionId(p) == subsliceRef) { @@ -102,6 +105,7 @@ OPTforImplementation(Client cntxt, MalBl InstrPtr r = copyInstruction(p); getArg(r, j) = varisfor[k]; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else// if (isSelect(p)) { @@ -181,6 +185,7 @@ OPTforImplementation(Client cntxt, MalBl pushInstruction(mb,t); } #endif + freeInstruction(p); done = 1; break; } else if ((isMapOp(p) || isMap2Op(p)) && (getFunctionId(p) == plusRef || getFunctionId(p) == minusRef) && allConstExcept(mb, p, j)) { @@ -200,6 +205,7 @@ OPTforImplementation(Client cntxt, MalBl varisfor[l] = varisfor[m] = varisfor[k]; varforvalue[l] = varforvalue[m] = getArg(r,0); pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else if (getModuleId(p) == groupRef && @@ -211,6 +217,7 @@ OPTforImplementation(Client cntxt, MalBl InstrPtr r = copyInstruction(p); getArg(r, j) = input; pushInstruction(mb,r); + freeInstruction(p); done = 1; break; } else { @@ -223,10 +230,13 @@ OPTforImplementation(Client cntxt, MalBl pushInstruction(mb, r); getArg(p, j) = getArg(r, 0); + actions++; } } } - if (!done) + if (done) + actions++; + else pushInstruction(mb, p); } diff --git a/sql/backends/monet5/for.c b/sql/backends/monet5/for.c --- a/sql/backends/monet5/for.c +++ b/sql/backends/monet5/for.c @@ -91,6 +91,7 @@ FORcompress_intern(char **comp_min_val, BAT *o = NULL; char buf[64]; int tt = b->ttype; + ptr mn = NULL, mx = NULL; if ( #ifdef HAVE_HGE @@ -99,18 +100,27 @@ FORcompress_intern(char **comp_min_val, tt != TYPE_lng && tt != TYPE_int) throw(SQL, "for.compress", SQLSTATE(3F000) "for compress: invalid column type"); - ptr mn = BATmin(NULL, b, NULL); - ptr mx = BATmax(NULL, b, NULL); + /* For now we only handle hge, lng, and int -> sht and bte */ + if (!(mn = BATmin(NULL, b, NULL))) + throw(SQL, "for.compress", GDK_EXCEPTION); + if (!(mx = BATmax(NULL, b, NULL))) { + GDKfree(mn); + throw(SQL, "for.compress", GDK_EXCEPTION); + } BUN cnt = BATcount(b); #ifdef HAVE_HGE if (b->ttype == TYPE_hge) { + GDKfree(mn); + GDKfree(mx); throw(SQL, "for.compress", SQLSTATE(3F000) "for compress: implement type hge"); } else #endif if (b->ttype == TYPE_lng) { lng min_val = *(lng*)mn; lng max_val = *(lng*)mx; + GDKfree(mn); + GDKfree(mx); if ((max_val-min_val) > GDK_sht_max) throw(SQL, "for.compress", SQLSTATE(3F000) "for compress: too large value spread for 'for' compression"); if ((max_val-min_val) < GDK_bte_max/2) { @@ -132,8 +142,12 @@ FORcompress_intern(char **comp_min_val, } snprintf(buf, 64, "FOR-" LLFMT, min_val); } else if (b->ttype == TYPE_int) { + GDKfree(mn); + GDKfree(mx); throw(SQL, "for.compress", SQLSTATE(3F000) "for compress: implement type int"); } else { + GDKfree(mn); + GDKfree(mx); throw(SQL, "for.compress", SQLSTATE(3F000) "for compress: type not yet implemented"); } if (!(*comp_min_val = GDKstrdup(buf))) { diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -8694,8 +8694,7 @@ merge_table_prune_and_unionize(visitor * /* check if the part falls within the bounds of the select expression else skip this (keep at least on part-table) */ if (!cmin && !cmax && first_attempt) { char *min = NULL, *max = NULL; - (void) sql_trans_ranges(v->sql->session->tr, col, &min, &max); - if (min && max) { + if (sql_trans_ranges(v->sql->session->tr, col, &min, &max) && min && max) { cmin = atom_general(v->sql->sa, &col->type, min); cmax = atom_general(v->sql->sa, &col->type, max); } diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -215,6 +215,7 @@ column_destroy(sqlstore *store, sql_colu _DELETE(c->min); _DELETE(c->max); _DELETE(c->def); + _DELETE(c->storage_type); _DELETE(c->base.name); _DELETE(c); } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list