Changeset: 10d8c77cbe45 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=10d8c77cbe45
Modified Files:
sql/backends/monet5/sql_optimizer.c
sql/server/rel_schema.c
Branch: timetrails
Log Message:
Forbid declaration of constraints on STREAM
A STREAM table is a temporary container, consumed by continous queries.
Therefore it does not make sense to allow column and table constraints.
diffs (74 lines):
diff --git a/sql/backends/monet5/sql_optimizer.c
b/sql/backends/monet5/sql_optimizer.c
--- a/sql/backends/monet5/sql_optimizer.c
+++ b/sql/backends/monet5/sql_optimizer.c
@@ -136,6 +136,7 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
}
}
}
+
if (getModuleId(p) == sqlRef && (getFunctionId(p) ==
bindidxRef)) {
char *sname = getVarConstant(mb, getArg(p, 1 +
p->retc)).val.sval;
//char *tname = getVarConstant(mb, getArg(p, 2 +
p->retc)).val.sval;
@@ -148,8 +149,13 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
sql_idx *i = mvc_bind_idx(m, s, idxname);
if ( i && isStream(i->t)) {
- setModuleId(p, basketRef);
- p->argc =5; // ignore partition
+/* STREAM TABLES are temporary containers and not subject to primary or
foreign key constraints.
+ * All related guards are removed from the plan.
+ */
+ p->argc =1;
+ setModuleId(p,batRef);
+ setFunctionId(p,newRef);
+ p = pushType(mb, p, getArgType(mb,p,0));
*alterpipe= "cquery_pipe";
}
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
@@ -293,6 +293,10 @@ column_constraint_type(mvc *sql, char *n
key_type kt = (s->token == SQL_UNIQUE) ? ukey : pkey;
sql_key *k;
+ if ( isStream(t)){
+ (void) sql_error(sql, 02, "42000!A stream table does
not support a key constraint\n");
+ return res;
+ }
if (kt == pkey && t->pkey) {
(void) sql_error(sql, 02, "42000!CONSTRAINT PRIMARY
KEY: a table can have only one PRIMARY KEY\n");
return res;
@@ -335,6 +339,10 @@ column_constraint_type(mvc *sql, char *n
(void) sql_error(sql, 02, "42S02!CONSTRAINT FOREIGN
KEY: no such table '%s'\n", rtname);
return res;
}
+ if ( isStream(rt)){
+ (void) sql_error(sql, 02, "42000!A stream table does
not support a foreign key constraint\n");
+ return res;
+ }
if (name && mvc_bind_key(sql, ss, name)) {
(void) sql_error(sql, 02, "42000!CONSTRAINT FOREIGN
KEY: key '%s' already exists", name);
return res;
@@ -565,6 +573,10 @@ table_constraint_type(mvc *sql, char *na
dnode *nms = s->data.lval->h;
sql_key *k;
+ if ( isStream(t)){
+ (void) sql_error(sql, 02, "42000!A stream table does
not support a key constraint\n");
+ return SQL_ERR;
+ }
if (kt == pkey && t->pkey) {
sql_error(sql, 02, "42000!CONSTRAINT PRIMARY KEY: a
table can have only one PRIMARY KEY\n");
return SQL_ERR;
@@ -617,6 +629,10 @@ table_constraint(mvc *sql, symbol *s, sq
if (opt_name != l->h->data.sval)
free(opt_name);
}
+ if ( isStream(t)){
+ (void) sql_error(sql, 02, "42000!A stream table does not
support a table constraint\n");
+ return SQL_ERR;
+ }
if (res != SQL_OK) {
sql_error(sql, 02, "M0M03!table constraint: wrong token ("
PTRFMT ") = %s\n", PTRFMTCAST s, token2string(s->token));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list