Changeset: d28853482462 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d28853482462 Modified Files: sql/backends/monet5/rel_bin.c Branch: default Log Message:
merged with oscar diffs (38 lines): diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c --- a/sql/backends/monet5/rel_bin.c +++ b/sql/backends/monet5/rel_bin.c @@ -775,13 +775,15 @@ exp_bin(backend *be, sql_exp *e, stmt *l assert(!e->r); if (exps) { int nrcols = 0; - int push_cond_exec = 0; + int push_cond_exec = 0, coalesce = 0; stmt *ncond = NULL, *ocond = cond; if (sel && strcmp(sql_func_mod(f->func), "calc") == 0 && strcmp(sql_func_imp(f->func), "ifthenelse") != 0) push_cands = 1; if (strcmp(sql_func_mod(f->func), "calc") == 0 && strcmp(sql_func_imp(f->func), "ifthenelse") == 0) push_cond_exec = 1; + if (strcmp(sql_func_mod(f->func), "") == 0 && strcmp(sql_func_imp(f->func), "") == 0 && strcmp(f->func->base.name, "coalesce") == 0) + coalesce = 1; assert(list_length(exps) == list_length(f->func->ops) || f->func->type == F_ANALYTIC || f->func->type == F_LOADER || f->func->vararg || f->func->varres); for (en = exps->h; en; en = en->next) { @@ -809,6 +811,17 @@ exp_bin(backend *be, sql_exp *e, stmt *l if (push_cands && es->nrcols) nrcands++; + if (coalesce && en->next) { + sql_subfunc *a = sql_bind_func(sql->sa, sql->session->schema, "isnull", tail_type(es), NULL, F_FUNC); + ncond = stmt_unop(be, es, a); + if (ocond) { + sql_subtype *bt = sql_bind_localtype("bit"); + sql_subfunc *a = sql_bind_func(sql->sa, sql->session->schema, "and", bt, bt, F_FUNC); + cond = stmt_binop(be, ocond, ncond, a); + } else { + cond = ncond; + } + } if (push_cond_exec && ncond) { /* handled then part */ sql_subtype *bt = sql_bind_localtype("bit"); sql_subfunc *a = sql_bind_func(sql->sa, sql->session->schema, "not", bt, NULL, F_FUNC); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list