Changeset: fee81895fc33 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fee81895fc33 Modified Files: sql/backends/monet5/sql_statement.c sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.test Branch: default Log Message:
When converting between decimals with the same scale and GDK types, don't generate a conversion statement diffs (41 lines): diff --git a/sql/backends/monet5/sql_statement.c b/sql/backends/monet5/sql_statement.c --- a/sql/backends/monet5/sql_statement.c +++ b/sql/backends/monet5/sql_statement.c @@ -3093,16 +3093,15 @@ stmt_convert(backend *be, stmt *v, stmt if (v->nr < 0) return NULL; - if ((t->type->localtype == f->type->localtype && - (t->type->eclass == f->type->eclass || - (EC_VARCHAR(f->type->eclass) && EC_VARCHAR(t->type->eclass))) && - !EC_INTERVAL(f->type->eclass) && - f->type->eclass != EC_DEC && - (t->digits == 0 || f->digits == t->digits) && - type_has_tz(t) == type_has_tz(f)) || - (EC_VARCHAR(f->type->eclass) && EC_VARCHAR(t->type->eclass) && f->digits > 0 && t->digits >= f->digits)) { - /* set output type. Despite the MAL code already being generated, - the output type may still be checked */ + if (f->type->eclass != EC_EXTERNAL && t->type->eclass != EC_EXTERNAL && + /* general cases */ + ((t->type->localtype == f->type->localtype && t->type->eclass == f->type->eclass && + !EC_INTERVAL(f->type->eclass) && f->type->eclass != EC_DEC && (t->digits == 0 || f->digits == t->digits) && type_has_tz(t) == type_has_tz(f)) || + /* trivial decimal cases */ + (f->type->eclass == EC_DEC && t->type->eclass == EC_DEC && f->scale == t->scale && f->type->localtype == t->type->localtype) || + /* trivial string cases */ + (EC_VARCHAR(f->type->eclass) && EC_VARCHAR(t->type->eclass) && (t->digits == 0 || (f->digits > 0 && t->digits >= f->digits))))) { + /* set output type. Despite the MAL code already being generated, the output type may still be checked */ tail_set_type(v, t); return v; } diff --git a/sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.test b/sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.test --- a/sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.test +++ b/sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.test @@ -69,7 +69,7 @@ call profiler.stoptrace() query I rowsort select count(*) from sys.tracelog() where stmt like '%batcalc.int%' ---- -1 +0 query I rowsort select count(*) from sys.tracelog() where stmt like '%batcalc.lng%' _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list