Changeset: 0627645faf05 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0627645faf05 Modified Files: monetdb5/mal/mal_builder.c monetdb5/mal/mal_instruction.c sql/backends/monet5/sql_gencode.c Branch: default Log Message:
Better search for constant re-use diffs (130 lines): diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c --- a/monetdb5/mal/mal_builder.c +++ b/monetdb5/mal/mal_builder.c @@ -227,7 +227,7 @@ getIntConstant(MalBlkPtr mb, int val) cst.vtype= TYPE_int; cst.val.ival= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_int,&cst); return _t; @@ -257,7 +257,7 @@ getWrdConstant(MalBlkPtr mb, wrd val) cst.vtype= TYPE_wrd; cst.val.wval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_wrd, &cst); return _t; @@ -287,7 +287,7 @@ getBteConstant(MalBlkPtr mb, bte val) cst.vtype= TYPE_bte; cst.val.btval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_bte, &cst); return _t; @@ -317,7 +317,7 @@ getOidConstant(MalBlkPtr mb, oid val) cst.vtype= TYPE_oid; cst.val.oval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_oid, &cst); return _t; @@ -362,7 +362,7 @@ getLngConstant(MalBlkPtr mb, lng val) cst.vtype= TYPE_lng; cst.val.lval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_lng, &cst); return _t; @@ -392,7 +392,7 @@ getShtConstant(MalBlkPtr mb, sht val) cst.vtype= TYPE_sht; cst.val.shval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_sht, &cst); return _t; @@ -421,7 +421,7 @@ getHgeConstant(MalBlkPtr mb, hge val) cst.vtype= TYPE_oid; cst.val.hval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_hge, &cst); return _t; @@ -449,7 +449,7 @@ getDblConstant(MalBlkPtr mb, dbl val) cst.vtype= TYPE_dbl; cst.val.dval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_dbl, &cst); return _t; @@ -479,7 +479,7 @@ getFltConstant(MalBlkPtr mb, flt val) cst.vtype= TYPE_flt; cst.val.fval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_flt, &cst); return _t; @@ -510,7 +510,7 @@ getStrConstant(MalBlkPtr mb, str val) if ((cst.val.sval= GDKstrdup(val)) == NULL) return -1; cst.len= (int) strlen(cst.val.sval); - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_str, &cst); return _t; @@ -543,7 +543,7 @@ getBitConstant(MalBlkPtr mb, bit val) cst.vtype= TYPE_bit; cst.val.btval= val; cst.len = 0; - _t= fndConstant(mb, &cst, mb->stop); + _t= fndConstant(mb, &cst, mb->vtop); if( _t < 0) _t = defConstant(mb, TYPE_bit, &cst); return _t; diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c --- a/monetdb5/mal/mal_instruction.c +++ b/monetdb5/mal/mal_instruction.c @@ -1471,9 +1471,10 @@ fndConstant(MalBlkPtr mb, const ValRecor k = mb->vtop - depth; if (k < 0) k = 0; - for (i = mb->vtop - 1; i >= k; i--) { + for (i=k; i < mb->vtop - 1; i++) + if( isVarConstant(mb,i)){ VarPtr v = getVar(mb, i); - if (v && isVarConstant(mb, i) && v->type == cst->vtype && ATOMcmp(cst->vtype, VALptr(&v->value), p) == 0) + if (v && v->type == cst->vtype && ATOMcmp(cst->vtype, VALptr(&v->value), p) == 0) return i; } return -1; diff --git a/sql/backends/monet5/sql_gencode.c b/sql/backends/monet5/sql_gencode.c --- a/sql/backends/monet5/sql_gencode.c +++ b/sql/backends/monet5/sql_gencode.c @@ -860,7 +860,7 @@ static InstrPtr pushSchema(MalBlkPtr mb, InstrPtr q, sql_table *t) { if (t->s) - return pushStr(mb, q, t->s->base.name); + return pushArgument(mb, q, getStrConstant(mb,t->s->base.name)); else return pushNil(mb, q, TYPE_str); } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list