Changeset: 3193046d6b05 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3193046d6b05
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_exp.c
Branch: nested
Log Message:
combine multi-results
diffs (76 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
@@ -656,6 +656,8 @@ set_value_list(backend *be, sql_exp *val
assert(is_values(vals_exp));
list *vals = exp_get_values(vals_exp);
sql_subtype *type = exp_subtype(vals->h->data);
+ bool single_value = list_length(vals) <= 1;
+ int multi_result = 0;
if (!type)
return sql_error(be->mvc, 02, SQLSTATE(42000) "Could not infer
the type of a value list column");
@@ -668,15 +670,31 @@ set_value_list(backend *be, sql_exp *val
if (!i)
return NULL;
-
- if (list_length(vals) == 1)
+ if (single_value)
return i;
list_append(l, i);
+
+ if (i->type == st_list && list_length(i->op4.lval) > 1)
+ multi_result = list_length(i->op4.lval);
}
/* n-tuples */
- //for (node *n = l->h; n; n = n->next) {
-
- //}
+ if (multi_result) {
+ list *rl = sa_list(be->mvc->sa);
+ for(int i = 0; i < multi_result; i++) {
+ node *n = l->h;
+ stmt *s = n->data;
+ stmt *input = list_fetch(s->op4.lval, i);
+ sql_subtype *type = tail_type(input);
+ list *nl = list_append(sa_list(be->mvc->sa), input);
+ for (; n; n = n->next) {
+ stmt *s = n->data;
+ stmt *input = list_fetch(s->op4.lval, i);
+ nl = list_append(nl, input);
+ }
+ append(rl, stmt_append_bulk(be, stmt_temp(be, type),
nl));
+ }
+ return stmt_list(be, rl);
+ }
return stmt_append_bulk(be, stmt_temp(be, type), l);
}
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -3682,7 +3682,7 @@ exp_check_composite_type(mvc *sql, sql_s
node *n, *m;
list *vals = NULL;
assert(t->type->composite);
- if (!exp_is_rel(exp) && !is_row(exp))
+ if (!exp_is_rel(exp) && is_row(exp) && !is_values(exp))
return sql_error( sql, 03, SQLSTATE(42000) "cannot convert
value into composite type '%s'", t->type->base.name);
if (exp_is_rel(exp)) {
@@ -3767,9 +3767,12 @@ exp_check_type(mvc *sql, sql_subtype *t,
if (t->type->composite || t->multiset) {
if (fromtype && subtype_cmp(t, fromtype) == 0)
return exp;
- if (t->multiset || !is_row(exp))
+ if (t->multiset && !is_row(exp))
return exp_check_multiset_type(sql, t, rel, exp, tpe);
- return exp_check_composite_type(sql, t, rel, exp, tpe);
+ if (t->type->composite && (is_row(exp) || is_values(exp)))
+ return exp_check_composite_type(sql, t, rel, exp, tpe);
+ if (is_values(exp))
+ return NULL;
}
if ((!fromtype || !fromtype->type) && rel_set_type_param(sql, t, rel,
exp, 0) == 0)
return exp;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]