Changeset: 984218fd9f1b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=984218fd9f1b
Modified Files:
sql/backends/monet5/sql.mx
sql/server/rel_schema.c
Branch: sciql
Log Message:
- add check if a CREATE ARRAY has at least one DIMENSION
- (not finished) trying to add exprssions which will be translated later into
stmt-s to call the MAL functions array.series() and array.filler().
diffs (78 lines):
diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx
--- a/sql/backends/monet5/sql.mx
+++ b/sql/backends/monet5/sql.mx
@@ -1573,6 +1573,7 @@
} else {
int pq;
+ /* TODO: do we need to optimise anything for SciQL? */
r = rel_optimizer(c, r);
pq = rel_is_point_query(r);
if (!pq)
@@ -2274,6 +2275,7 @@
} break;
case DDL_CREATE_TABLE:
case DDL_CREATE_VIEW:
+ case DDL_CREATE_ARRAY:
{
sql_table *t = *(sql_table**) getArgReference(stk, pci, 3);
int temp = *(int*) getArgReference(stk, pci, 4);
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -881,6 +881,8 @@
((temp == SQL_MERGE_TABLE)?tt_merge_table:
((temp == SQL_ARRAY)? tt_array:tt_table));
char *t_a = (tt == tt_array)?"ARRAY":"TABLE";
+ /* TODO: compute 'fixed' somewhere somehow */
+ bit fixed = 1, found_dim = 0;
(void)create;
if (sname && !(s = mvc_bind_schema(sql, sname)))
@@ -916,13 +918,44 @@
for (n = columns->h; n; n = n->next) {
symbol *sym = n->data.sym;
int res = table_element(sql, sym, s, t, 0);
+ found_dim = sym->data.lval->h->next->next->next &&
sym->data.lval->h->next->next->next->type == type_symbol &&
sym->data.lval->h->next->next->next->data.sym->token == SQL_DIMENSION;
if (res == SQL_ERR)
return NULL;
}
+
+ if (tt == tt_array && !found_dim)
+ return sql_error(sql, 02, "CREATE ARRAY: an array must
have at least one dimension");
+
temp = (tt == tt_table || tt == tt_array)?temp:SQL_PERSIST;
- /* TODO: is DDL_CREATE_TABLE sufficient for arrays? */
- return rel_table(sql, DDL_CREATE_TABLE, sname, t, temp);
+ /* For unbounded arrays we don't immediately create the columns
*/
+ if ((tt == tt_table) || (tt == tt_array && !fixed)) {
+ /* TODO: is DDL_CREATE_TABLE sufficient for arrays? */
+ return rel_table(sql, DDL_CREATE_TABLE, sname, t, temp);
+ } else {
+ sql_rel *res = NULL;
+ list *prjs = new_exp_list(sql->sa);
+ node *col = NULL;
+
+ assert(tt == tt_array && fixed);
+
+ for (col = t->columns.set->h; col; col = col->next){
+ sql_column *sc = (sql_column *) col->data;
+ list *args = new_exp_list(sql->sa);
+ if (sc->dim){
+ append(args, exp_atom_lng(sql->sa,
*sc->dim->start));
+ append(args, exp_atom_lng(sql->sa,
*sc->dim->step));
+ append(args, exp_atom_lng(sql->sa,
*sc->dim->stop));
+ /* TODO: compute the 'N' and 'M' */
+ append(args, exp_atom_int(sql->sa, 1));
+ append(args, exp_atom_int(sql->sa, 4));
+
+ append(prjs, exp_op(sql->sa, args,
sql_find_func(sql->sa, sql->session->schema, "series", 5)));
+ }
+ }
+ res = rel_table(sql, DDL_CREATE_TABLE, sname, t, temp);
+ return rel_insert(sql, res, rel_project(sql->sa, res,
prjs));
+ }
} else { /* [col name list] as subquery with or without data */
/* TODO: handle create_array_as_subquery??? */
sql_rel *sq = NULL, *res = NULL;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list