Re: MonetDB: default - Avoid coercion in aggr.subavg
According to Mtest, this makes TPCh Q1 return a wrong result. I suspect because this now indeed removes a scale-changing cast. Stefan ----- Original Message -----
Changeset: 9779801a1482 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9779801a1482 Modified Files: monetdb5/optimizer/opt_coercion.c Branch: default Log Message:
Avoid coercion in aggr.subavg Another example where we can avoid coercions in most cases
diffs (43 lines):
diff --git a/monetdb5/optimizer/opt_coercion.c b/monetdb5/optimizer/opt_coercion.c --- a/monetdb5/optimizer/opt_coercion.c +++ b/monetdb5/optimizer/opt_coercion.c @@ -84,6 +84,24 @@ coercionOptimizerCalcStep(MalBlkPtr mb, return; }
+static void +coercionOptimizerAggrStep(MalBlkPtr mb, int i, Coercion *coerce) +{ + InstrPtr p = getInstrPtr(mb,i); + int r, k; + + if( getModuleId(p) != aggrRef || getFunctionId(p) == 0) return; + if( ! (getFunctionId(p) == subavgRef ) || p->argc !=6) + return; + + r = getColumnType(getVarType(mb, getArg(p,0))); + k = getArg(p,1); + // check the digits/scale + if( r == TYPE_dbl && coerce[k].src ) + getArg(p,1) = coerce[getArg(p,1)].src; + return; +} + int OPTcoercionImplementation(Client cntxt,MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { @@ -117,6 +135,14 @@ OPTcoercionImplementation(Client cntxt,M coerce[k].scale= getVarConstant(mb,getArg(p,4)).val.ival; } #endif + if ( getModuleId(p) == batcalcRef && getFunctionId(p) == dblRef && p->retc == 1 && ((p->argc == 3 && isVarConstant(mb,getArg(p,1))) || p->argc ==2) ){ + k = getArg(p,0); + coerce[k].pc= i; + coerce[k].totype= TYPE_dbl; + coerce[k].src= getArg(p,1 + (p->argc ==3)); + coerce[k].fromtype= getColumnType(getArgType(mb,p,1 + (p->argc ==3))); + } + coercionOptimizerAggrStep(mb, i, coerce); coercionOptimizerCalcStep(mb, i, coerce); if (getModuleId(p)==calcRef && p->argc == 2) { k= coercionOptimizerStep(mb, i, p); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
participants (1)
-
Stefan Manegold