Changeset: 40fd199703b6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=40fd199703b6
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_statement.c
        sql/backends/monet5/sql_statement.h
Branch: Aug2018
Log Message:

backport fix of 6712


diffs (74 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
@@ -487,7 +487,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                }
                if (!l) 
                        return NULL;
-               s = stmt_convert(be, l, from, to);
+               s = stmt_convert(be, l, from, to, sel);
        }       break;
        case e_func: {
                node *en;
@@ -1080,7 +1080,7 @@ check_types(backend *be, sql_subtype *ct
                    (c == 3 && tpe != type_cast)) { 
                        s = NULL;
                } else {
-                       s = stmt_convert(be, s, st, ct);
+                       s = stmt_convert(be, s, st, ct, NULL);
                }
        } 
        if (!s) {
@@ -2787,6 +2787,11 @@ rel2bin_select(backend *be, sql_rel *rel
                if (s->nrcols == 0){
                        if (!predicate && sub)
                                predicate = stmt_const(be, bin_first_column(be, 
sub), stmt_bool(be, 1));
+                       if (e->type != e_cmp) {
+                               sql_subtype *bt = sql_bind_localtype("bit");
+ 
+                               s = stmt_convert(be, s, exp_subtype(e), bt, 
NULL);
+                       }
                        sel = stmt_uselect(be, predicate, s, cmp_equal, sel, 0);
                } else if (e->type != e_cmp) {
                        sel = stmt_uselect(be, s, stmt_bool(be, 1), cmp_equal, 
NULL, 0);
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
@@ -2669,7 +2669,7 @@ stmt_exception(backend *be, stmt *cond, 
 }
 
 stmt *
-stmt_convert(backend *be, stmt *v, sql_subtype *f, sql_subtype *t)
+stmt_convert(backend *be, stmt *v, sql_subtype *f, sql_subtype *t, stmt *sel)
 {
        MalBlkPtr mb = be->mb;
        InstrPtr q = NULL;
@@ -2722,6 +2722,8 @@ stmt_convert(backend *be, stmt *v, sql_s
                /* scale of the current decimal */
                q = pushInt(mb, q, f->scale);
        q = pushArgument(mb, q, v->nr);
+       if (sel && v->nrcols && f->type->eclass != EC_DEC && 
!EC_TEMP_FRAC(t->type->eclass) && !EC_INTERVAL(t->type->eclass))
+               q = pushArgument(mb, q, sel->nr);
 
        if (t->type->eclass == EC_DEC || EC_TEMP_FRAC(t->type->eclass) || 
EC_INTERVAL(t->type->eclass)) {
                /* digits, scale of the result decimal */
@@ -2763,6 +2765,7 @@ stmt_convert(backend *be, stmt *v, sql_s
                        return NULL;
                }
                s->op1 = v;
+               s->op2 = sel;
                s->nrcols = 0;  /* function without arguments returns single 
value */
                s->key = v->key;
                s->nrcols = v->nrcols;
diff --git a/sql/backends/monet5/sql_statement.h 
b/sql/backends/monet5/sql_statement.h
--- a/sql/backends/monet5/sql_statement.h
+++ b/sql/backends/monet5/sql_statement.h
@@ -211,7 +211,7 @@ extern stmt *stmt_sample(backend *be, st
 extern stmt *stmt_order(backend *be, stmt *s, int direction);
 extern stmt *stmt_reorder(backend *be, stmt *s, int direction, stmt 
*orderby_ids, stmt *orderby_grp);
 
-extern stmt *stmt_convert(backend *sa, stmt *v, sql_subtype *from, sql_subtype 
*to);
+extern stmt *stmt_convert(backend *sa, stmt *v, sql_subtype *from, sql_subtype 
*to, stmt *sel);
 extern stmt *stmt_unop(backend *be, stmt *op1, sql_subfunc *op);
 extern stmt *stmt_binop(backend *be, stmt *op1, stmt *op2, sql_subfunc *op);
 extern stmt *stmt_Nop(backend *be, stmt *ops, sql_subfunc *op);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to