Changeset: c997d7bc7116 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c997d7bc7116
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
Branch: pushcands
Log Message:
Trying to fix some tests, but most of this code is not mine, so I can't do that
much
diffs (177 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
@@ -682,7 +682,7 @@ exp_bin_or(backend *be, sql_exp *e, rel_
static stmt *
exp2bin_case(backend *be, sql_exp *fe, rel_bin_stmt *left, rel_bin_stmt
*right, int depth)
{
- stmt *res = NULL, *ires = NULL, *rsel = NULL, *osel = NULL, *ncond =
NULL, *ocond = NULL, *cond = NULL, *isel = left ? left->cand : NULL, *ocand =
left ? left->cand : NULL;
+ stmt *res = NULL, *ires = NULL, *rsel = left ? left->cand : NULL, *osel
= NULL, *ncond = NULL, *ocond = NULL, *cond = NULL, *isel = left ? left->cand :
NULL;
int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left ||
!left->nrcols));
char name[16], *nme = NULL;
sql_subtype *bt = sql_bind_localtype("bit");
@@ -721,7 +721,7 @@ exp2bin_case(backend *be, sql_exp *fe, r
if (!es) {
if (left)
- left->cand = ocand;
+ left->cand = rsel;
return NULL;
}
if (!single_value) {
@@ -813,17 +813,17 @@ exp2bin_case(backend *be, sql_exp *fe, r
next_cond = !next_cond;
}
if (left)
- left->cand = ocand;
+ left->cand = rsel;
if (single_value)
- res = stmt_var(be, NULL, nme, exp_subtype(fe), 0, 2, ocand);
- res->cand = ocand;
+ res = stmt_var(be, NULL, nme, exp_subtype(fe), 0, 2, rsel);
+ res->cand = rsel;
return res;
}
static stmt *
exp2bin_casewhen(backend *be, sql_exp *fe, rel_bin_stmt *left, rel_bin_stmt
*right, int depth)
{
- stmt *res = NULL, *ires = NULL, *rsel = NULL, *osel = NULL, *ncond =
NULL, *ocond = NULL, *cond = NULL, *isel = left ? left->cand : NULL, *ocand =
left ? left->cand : NULL;
+ stmt *res = NULL, *ires = NULL, *rsel = left ? left->cand : NULL, *osel
= NULL, *ncond = NULL, *ocond = NULL, *cond = NULL, *isel = left ? left->cand :
NULL;
int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left ||
!left->nrcols));
char name[16], *nme = NULL;
sql_subtype *bt = sql_bind_localtype("bit");
@@ -884,7 +884,7 @@ exp2bin_casewhen(backend *be, sql_exp *f
if (!es) {
if (left)
- left->cand = ocand;
+ left->cand = rsel;
return NULL;
}
if (next_cond) {
@@ -910,7 +910,7 @@ exp2bin_casewhen(backend *be, sql_exp *f
}
assert(l->cand == es->cand);
}
- es = stmt_binop(be, l, es, NULL, cmp);
+ es = stmt_binop(be, l, es, es->cand, cmp);
}
if (!single_value) {
/* create result */
@@ -999,17 +999,17 @@ exp2bin_casewhen(backend *be, sql_exp *f
next_cond = !next_cond;
}
if (left)
- left->cand = ocand;
+ left->cand = rsel;
if (single_value)
- res = stmt_var(be, NULL, nme, exp_subtype(fe), 0, 2, ocand);
- res->cand = ocand;
+ res = stmt_var(be, NULL, nme, exp_subtype(fe), 0, 2, rsel);
+ res->cand = rsel;
return res;
}
static stmt*
exp2bin_coalesce(backend *be, sql_exp *fe, rel_bin_stmt *left, rel_bin_stmt
*right, int depth)
{
- stmt *res = NULL, *rsel = NULL, *osel = NULL, *ncond = NULL, *ocond =
NULL, *isel = left ? left->cand : NULL, *ocand = left ? left->cand : NULL;
+ stmt *res = NULL, *rsel = left ? left->cand : NULL, *osel = NULL,
*ncond = NULL, *ocond = NULL, *isel = left ? left->cand : NULL;
int single_value = (fe->card <= CARD_ATOM && (!left || !left->nrcols));
char name[16], *nme = NULL;
sql_subtype *bt = sql_bind_localtype("bit");
@@ -1040,7 +1040,7 @@ exp2bin_coalesce(backend *be, sql_exp *f
if (!es) {
if (left)
- left->cand = ocand;
+ left->cand = rsel;
return NULL;
}
/* create result */
@@ -1057,7 +1057,7 @@ exp2bin_coalesce(backend *be, sql_exp *f
if (en->next) {
sql_subfunc *a = sql_bind_func(be->mvc,
"sys", "isnotnull", tail_type(es), NULL, F_FUNC);
- ncond = stmt_unop(be, es, NULL, a);
+ ncond = stmt_unop(be, es, nsel, a);
if (ncond->nrcols == 0) {
stmt *l =
bin_find_smallest_column(be, left);
if (nsel && l)
@@ -1120,10 +1120,10 @@ exp2bin_coalesce(backend *be, sql_exp *f
}
}
if (left)
- left->cand = ocand;
+ left->cand = rsel;
if (single_value)
- res = stmt_var(be, NULL, nme, exp_subtype(fe), 0, 2, ocand);
- res->cand = ocand;
+ res = stmt_var(be, NULL, nme, exp_subtype(fe), 0, 2, rsel);
+ res->cand = rsel;
return res;
}
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
@@ -1337,7 +1337,7 @@ stmt_genselect(backend *be, stmt *lops,
MalBlkPtr mb = be->mb;
InstrPtr q = NULL;
const char *mod = sql_func_mod(f->func), *op = sql_func_imp(f->func);
- int k, push_cands = sel && (strcmp(mod, "pcre") == 0 || strcmp(mod,
"algebra") == 0), all_cands_pushed = 1;
+ int k, push_cands = strcmp(mod, "pcre") == 0 || strcmp(mod, "algebra")
== 0, all_cands_pushed = 1;
if (backend_create_subfunc(be, f, NULL) < 0)
return NULL;
@@ -2998,9 +2998,9 @@ stmt_convert(backend *be, stmt *v, stmt
/* Lookup the sql convert function, there is no need
* for single value vs bat, this is handled by the
* mal function resolution */
- if (v->nrcols == 0 && (!sel || sel->nrcols == 0)) { /* simple calc
*/
+ if (v->nrcols == 0) { /* simple calc */
q = newStmtArgs(mb, calcRef, convert, 13);
- } else if ((v->nrcols > 0 || (sel && sel->nrcols > 0)) && !push_cands) {
+ } else if (v->nrcols > 0 && !push_cands) {
int type = t->type->localtype;
/* with our current implementation, all internal SQL types have
candidate list support on their conversions */
@@ -3013,8 +3013,6 @@ stmt_convert(backend *be, stmt *v, stmt
q = pushStr(mb, q, convertMultiplexMod(calcRef, convert));
q = pushStr(mb, q, convertMultiplexFcn(convert));
} else {
- if (v->nrcols == 0 && sel && !v->cand)
- v = stmt_project_column_on_cand(be, sel, v);
q = newStmtArgs(mb, batcalcRef, convert, 13);
}
@@ -3114,8 +3112,8 @@ stmt_Nop(backend *be, stmt *ops, stmt *s
InstrPtr q = NULL;
const char *mod = sql_func_mod(f->func), *fimp = sql_func_imp(f->func);
sql_subtype *tpe = NULL;
- int push_cands = sel && (strcmp(mod, "calc") == 0 || strcmp(mod,
"mmath") == 0 || strcmp(mod, "mtime") == 0 ||
- strcmp(mod, "blob") == 0 || (strcmp(mod, "str") == 0
&& batstr_func_has_candidates(sql_func_imp(f->func))));
+ int push_cands = strcmp(mod, "calc") == 0 || strcmp(mod, "mmath") == 0
|| strcmp(mod, "mtime") == 0 ||
+ strcmp(mod, "blob") == 0 || (strcmp(mod, "str") == 0 &&
batstr_func_has_candidates(sql_func_imp(f->func)));
node *n;
stmt *o = NULL;
@@ -3212,7 +3210,7 @@ stmt_Nop(backend *be, stmt *ops, stmt *s
q = pushArgument(mb, q, op->nr);
}
/* push candidate lists if that's the case */
- if (f->func->type == F_FUNC && f->func->lang == FUNC_LANG_INT
&& push_cands) {
+ if (sel && push_cands && f->func->type == F_FUNC &&
f->func->lang == FUNC_LANG_INT) {
for (n = ops->op4.lval->h; n; n = n->next) {
stmt *op = n->data;
@@ -3226,7 +3224,7 @@ stmt_Nop(backend *be, stmt *ops, stmt *s
}
}
/* special case for round function on decimals */
- if (strcmp(fimp, "round") == 0 && tpe && tpe->type->eclass ==
EC_DEC && ops->op4.lval->h && ops->op4.lval->h->data) {
+ if (strcmp(mod, "calc") == 0 && strcmp(fimp, "round") == 0 &&
tpe && tpe->type->eclass == EC_DEC && ops->op4.lval->h &&
ops->op4.lval->h->data) {
q = pushInt(mb, q, tpe->digits);
q = pushInt(mb, q, tpe->scale);
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list