Changeset: 26477e56bd9b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=26477e56bd9b
Modified Files:
        sql/backends/monet5/sql.mx
        sql/include/sql_relation.h
        sql/server/rel_schema.c
        sql/server/rel_semantic.c
Branch: SciQL-2
Log Message:

ALTER ARRAY is not supported yet, give proper err. msg.
Also enforce using correct syntax: don't allow altering arrays with ALTER 
TABLE, and vice versa


diffs (88 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
@@ -2188,7 +2188,7 @@ drop_table(mvc *sql, char *sname, char *
                return sql_message("42000!DROP %s: cannot drop system %s '%s'", 
(tt==tt_table)?"TABLE":"ARRAY", (tt==tt_table)?"table":"array", tname);
        } else if (!schema_privs(sql->role_id, s) && !(isTempSchema(s) && 
t->persistence == SQL_LOCAL_TEMP)){
                return sql_message("42000!DROP %s: access denied for %s to 
schema ;'%s'", (tt==tt_table)?"TABLE":"ARRAY", stack_get_string(sql, 
"current_user"), s->base.name);
-       } else if ((tt == tt_table && t->valence > 0) || (tt == tt_array && 
t->valence == 0)) {
+       } else if ((tt == tt_table && isArray(t)) || (tt == tt_array && 
isTable(t))) {
                return sql_message("42S02!DROP %s: '%s' is %s not %s, ", 
(tt==tt_table)?"TABLE":"ARRAY", tname, (tt==tt_table)?"an array":"a table", 
(tt==tt_table)?"a table":"an array");
        }
 
diff --git a/sql/include/sql_relation.h b/sql/include/sql_relation.h
--- a/sql/include/sql_relation.h
+++ b/sql/include/sql_relation.h
@@ -105,12 +105,13 @@ typedef struct expression {
 #define DDL_DROP_VIEW    30
 #define DDL_DROP_CONSTRAINT    31
 #define DDL_ALTER_TABLE  32
+#define DDL_ALTER_ARRAY  33
 
-#define DDL_CREATE_TYPE 33
-#define DDL_DROP_TYPE   34
+#define DDL_CREATE_TYPE 34
+#define DDL_DROP_TYPE   35
 
-#define DDL_CREATE_INDEX  35
-#define DDL_DROP_INDEX    36
+#define DDL_CREATE_INDEX  36
+#define DDL_DROP_INDEX    37
 
 #define DDL_CREATE_FUNCTION 41 
 #define DDL_DROP_FUNCTION   42 
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
@@ -1177,7 +1177,7 @@ get_schema_name( mvc *sql, char *sname, 
 }
 
 static sql_rel *
-rel_alter_table(mvc *sql, dlist *qname, symbol *te)
+rel_alter_table(mvc *sql, int cat_type, dlist *qname, symbol *te)
 {
        char *sname = qname_schema(qname);
        char *tname = qname_table(qname);
@@ -1192,7 +1192,17 @@ rel_alter_table(mvc *sql, dlist *qname, 
                s = cur_schema(sql);
 
        if ((t = mvc_bind_table(sql, s, tname)) == NULL) {
-               return sql_error(sql, 02, "42S02!ALTER TABLE: no such table 
'%s'", tname);
+               return sql_error(sql, 02, "42S02!ALTER %s: no such %s '%s'",
+                               cat_type == DDL_ALTER_TABLE?"TABLE":"ARRAY", 
tname,
+                               cat_type == DDL_ALTER_TABLE?"table":"array");
+       } else if ((cat_type == DDL_ALTER_TABLE && isArray(t)) ||
+               (cat_type == DDL_ALTER_ARRAY && isTable(t))) {
+               return sql_error(sql, 02, "42S02!ALTER %s: '%s' is %s not %s",
+                               cat_type == DDL_ALTER_TABLE?"TABLE":"ARRAY", 
tname,
+                               cat_type == DDL_ALTER_TABLE?"an array":"a 
table",
+                               cat_type == DDL_ALTER_TABLE?"a table":"an 
array");
+       } else if (cat_type == DDL_ALTER_ARRAY) {
+               return sql_error(sql, 02, "42S02!ALTER ARRAY: altering array 
elements not supported yet");
        } else {
                node *n;
                sql_rel *res = NULL, *r;
@@ -1756,10 +1766,12 @@ rel_schemas(mvc *sql, symbol *s)
                ret = rel_schema(sql->sa, DDL_DROP_VIEW, sname, tname, 
l->h->next->data.i_val);
        }       break;
        case SQL_ALTER_TABLE:
+       case SQL_ALTER_ARRAY:
        {
                dlist *l = s->data.lval;
 
                ret = rel_alter_table(sql, 
+                       (s->token == 
SQL_ALTER_TABLE)?DDL_ALTER_TABLE:DDL_ALTER_ARRAY,
                        l->h->data.lval,        /* table name */
                        l->h->next->data.sym);/* table element */
        }       break;
diff --git a/sql/server/rel_semantic.c b/sql/server/rel_semantic.c
--- a/sql/server/rel_semantic.c
+++ b/sql/server/rel_semantic.c
@@ -180,6 +180,7 @@ rel_semantic(mvc *sql, symbol *s)
        case SQL_DROP_ARRAY:
        case SQL_DROP_VIEW:
        case SQL_ALTER_TABLE:
+       case SQL_ALTER_ARRAY:
 
        case SQL_GRANT:
        case SQL_REVOKE:
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to