Changeset: e2f7077d995d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e2f7077d995d
Modified Files:
monetdb5/optimizer/opt_mergetable.c
Branch: Jun2020
Log Message:
in mergetable optimizer all inserts are handled by the last partition, ie
we need to make sure we cleanup any select on inserts of a partitioned table
improved nil bat detection, to improve on functions handling/working on
partitions
diffs (83 lines):
diff --git a/monetdb5/optimizer/opt_mergetable.c
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -59,15 +59,6 @@ is_a_mat(int idx, matlist_t *ml)
}
static int
-was_a_mat(int idx, matlist_t *ml){
- int i;
- for(i =0; i<ml->top; i++)
- if (ml->v[i].mv == idx)
- return i;
- return -1;
-}
-
-static int
nr_of_mats(InstrPtr p, matlist_t *ml)
{
int j,cnt=0;
@@ -82,7 +73,7 @@ nr_of_bats(MalBlkPtr mb, InstrPtr p)
{
int j,cnt=0;
for(j=p->retc; j<p->argc; j++)
- if (isaBatType(getArgType(mb,p,j)))
+ if (isaBatType(getArgType(mb,p,j)) && !isVarConstant(mb,
getArg(p,j)))
cnt++;
return cnt;
}
@@ -92,7 +83,7 @@ nr_of_nilbats(MalBlkPtr mb, InstrPtr p)
{
int j,cnt=0;
for(j=p->retc; j<p->argc; j++)
- if (getArgType(mb,p,j) == TYPE_bat)
+ if (getArgType(mb,p,j) == TYPE_bat ||
(isaBatType(getArgType(mb, p, j)) && isVarConstant(mb, getArg(p,j)) &&
getVarConstant(mb, getArg(p,j)).val.bval == bat_nil))
cnt++;
return cnt;
}
@@ -1903,7 +1894,7 @@ OPTmergetableImplementation(Client cntxt
InstrPtr *old;
matlist_t ml;
int oldtop, fm, fn, fo, fe, i, k, m, n, o, e, slimit, bailout = 0;
- int size=0, match, actions=0, distinct_topn = 0, /*topn_res = 0,*/
groupdone = 0, *vars;
+ int size=0, match, actions=0, distinct_topn = 0, /*topn_res = 0,*/
groupdone = 0, *vars, maxvars;
char buf[256], *group_input;
lng usec = GDKusec();
str msg = MAL_SUCCEED;
@@ -1914,6 +1905,7 @@ OPTmergetableImplementation(Client cntxt
oldtop= mb->stop;
vars = (int*) GDKmalloc(sizeof(int)* mb->vtop);
+ maxvars = mb->vtop;
group_input = (char*) GDKzalloc(sizeof(char)* mb->vtop);
if (vars == NULL || group_input == NULL){
if (vars)
@@ -1985,7 +1977,6 @@ OPTmergetableImplementation(Client cntxt
/* not idea how to detect this yet */
//distinct_topn = 1;
}
- GDKfree(vars);
GDKfree(group_input);
ml.horigin = 0;
@@ -2316,11 +2307,10 @@ OPTmergetableImplementation(Client cntxt
}
/* select on insert, should use last tid only */
- if (/* DISABLES CODE */ (0))
if (match == 1 && fm == 2 && isSelect(p) && p->retc == 1 &&
(m=is_a_mat(getArg(p,fm), &ml)) >= 0 &&
!ml.v[m].packed && /* not packed yet */
- was_a_mat(getArg(p,fm-1), &ml) < 0){ /* not previously
packed */
+ (getArg(p,fm-1) > maxvars ||
getModuleId(old[vars[getArg(p,fm-1)]]) == sqlRef)){
if((r = copyInstruction(p)) == NULL) {
msg =
createException(MAL,"optimizer.mergetable",SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto cleanup;
@@ -2437,6 +2427,7 @@ OPTmergetableImplementation(Client cntxt
freeInstruction(ml.v[i].mi);
}
cleanup:
+ if (vars) GDKfree(vars);
if (ml.v) GDKfree(ml.v);
if (ml.horigin) GDKfree(ml.horigin);
if (ml.torigin) GDKfree(ml.torigin);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list