Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16:/tmp/cvs-serv11322/src/server

Modified Files:
        sql_parser.mx sql_psm.mx sql_select.mx sql_semantic.mx 
Log Message:
added DROP PROCEDURE cases
added CREATE PROCEDURE 
Both untested

fixed bug (crash) in select * from 'variable';


Index: sql_psm.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_psm.mx,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- sql_psm.mx  29 Apr 2007 10:12:51 -0000      1.37
+++ sql_psm.mx  1 May 2007 22:03:10 -0000       1.38
@@ -607,7 +607,7 @@
 }
 
 stmt* 
-drop_func(mvc *sql, dlist *qname, dlist *typelist, int drop_action)
+drop_func(mvc *sql, dlist *qname, dlist *typelist, int drop_action, int 
is_func)
 {
        char *name = qname_table(qname);
        char *sname = qname_schema(qname);
@@ -616,8 +616,12 @@
        sql_subfunc *sub_func = NULL;
        sql_func *func = NULL;
 
+       char *F = is_func?"FUNCTION":"PROCEDURE";
+       char *f = is_func?"function":"procedure";
+
+
        if (sname && !(s = mvc_bind_schema(sql, sname)))
-               return sql_error(sql, 02, "DROP FUNCTION: no such schema '%s'", 
sname);
+               return sql_error(sql, 02, "DROP %s: no such schema '%s'", F, 
sname);
 
        if (s == NULL) 
                s =  cur_schema(sql);
@@ -631,11 +635,10 @@
                }
                if (sub_func)
                        func = sub_func->func;
-       }
-       else {
+       } else {
                list_func = schema_bind_func(sql,s,name);
                if (list_func && list_func->cnt > 1)
-                       return sql_error(sql, 02, "DROP FUNCTION: there are 
more than one function called '%s', please use the full signature", name);
+                       return sql_error(sql, 02, "DROP %s: there are more than 
one function called '%s', please use the full signature", F, name);
                if (list_func && list_func->cnt == 1)
                        func = (sql_func*) list_func->h->data;
        }
@@ -660,25 +663,28 @@
                                
                                list_destroy(type_list);
                                
-                               return sql_error(sql, 02, "DROP FUNCTION: no 
such function '%s' (%s)", name, arg_list);
+                               return sql_error(sql, 02, "DROP %s: no such %s 
'%s' (%s)", F, f, name, arg_list);
                        }
                                
-                       return sql_error(sql, 02, "DROP FUNCTION: no such 
function '%s' ()", name);
+                       return sql_error(sql, 02, "DROP %s: no such %s '%s' 
()", F, f, name);
 
                } else
-                       return sql_error(sql, 02, "DROP FUNCTION: no such 
function '%s'", name);
-       } 
+                       return sql_error(sql, 02, "DROP %s: no such %s '%s'", 
F, f, name);
+       } else if ((is_func && !func->res.type) || 
+                  (!is_func && func->res.type)) {
+               return sql_error(sql, 02, "DROP %s: cannot drop %s '%s'", F, 
is_func?"procedure":"function", name);
+       }
        
        list_destroy(type_list);
 
        
        if (!schema_privs(sql->role_id, s)) {
-               return sql_error(sql, 02, "DROP FUNCTION: access denied for %s 
to schema ;'%s'", stack_get_string(sql, "current_user"), s->base.name);
+               return sql_error(sql, 02, "DROP %s: access denied for %s to 
schema ;'%s'", F, stack_get_string(sql, "current_user"), s->base.name);
        }
        
        
        if (!drop_action && mvc_check_dependency(sql, func->base.id, 
FUNC_DEPENDENCY))
-               return sql_error(sql, 02, "DROP FUNCTION: there are functions 
dependent on function %s;", func->base.name);
+               return sql_error(sql, 02, "DROP %s: there are functions 
dependent on %s %s;", F, f, func->base.name);
        
        mvc_drop_func(sql, s, func, drop_action);
 
@@ -686,7 +692,7 @@
 }
 
 stmt* 
-drop_all_func(mvc *sql, dlist *qname, int drop_action)
+drop_all_func(mvc *sql, dlist *qname, int drop_action, int is_func)
 {
        char *name = qname_table(qname);
        char *sname = qname_schema(qname);
@@ -695,8 +701,11 @@
        sql_func *func = NULL;
        node *n = NULL;
 
+       char *F = is_func?"FUNCTION":"PROCEDURE";
+       char *f = is_func?"function":"procedure";
+
        if (sname && !(s = mvc_bind_schema(sql, sname)))
-               return sql_error(sql, 02, "DROP FUNCTION: no such schema '%s'", 
sname);
+               return sql_error(sql, 02, "DROP %s: no such schema '%s'", F, 
sname);
 
        if (s == NULL) 
                s =  cur_schema(sql);
@@ -704,11 +713,11 @@
        list_func = schema_bind_func(sql,s,name);
        
        if (!list_func) { 
-                       return sql_error(sql, 02, "DROP ALL FUNCTION: no such 
functions '%s'", name);
+                       return sql_error(sql, 02, "DROP ALL %s: no such %s 
'%s'", F, f, name);
        } 
        
        if (!schema_privs(sql->role_id, s)) {
-               return sql_error(sql, 02, "DROP FUNCTION: access denied for %s 
to schema ;'%s'", stack_get_string(sql, "current_user"), s->base.name);
+               return sql_error(sql, 02, "DROP %s: access denied for %s to 
schema ;'%s'", F, stack_get_string(sql, "current_user"), s->base.name);
        }
        
        
@@ -716,7 +725,10 @@
                func = (sql_func *) n->data;
 
                if (!drop_action && mvc_check_dependency(sql, func->base.id, 
FUNC_DEPENDENCY))
-                       return sql_error(sql, 02, "DROP FUNCTION: there are 
functions dependent on function %s;", func->base.name);
+                       return sql_error(sql, 02, "DROP %s: there are functions 
dependent on %s %s;", F, f, func->base.name);
+               if ((is_func && !func->res.type) || 
+                  (!is_func && func->res.type)) 
+                       return sql_error(sql, 02, "DROP %s: cannot drop %s 
'%s'", F, is_func?"procedure":"function", name);
        }
                
        mvc_drop_all_func(sql, s, list_func, drop_action);
@@ -741,13 +753,15 @@
                sql->type = Q_SCHEMA;
        }       break;
        case SQL_DROP_FUNC:
+       case SQL_DROP_PROC:
        {
                dlist *l = s->data.lval;
+               int is_func = (s->token == SQL_DROP_FUNC);
                
                if (l->h->next->data.ival)
-                       ret = drop_all_func(sql, l->h->data.lval, 
l->h->next->next->next->data.ival);
+                       ret = drop_all_func(sql, l->h->data.lval, 
l->h->next->next->next->data.ival, is_func);
                else
-                       ret = drop_func(sql, l->h->data.lval, 
l->h->next->next->data.lval, l->h->next->next->next->data.ival);
+                       ret = drop_func(sql, l->h->data.lval, 
l->h->next->next->data.lval, l->h->next->next->next->data.ival, is_func);
                sql->type = Q_SCHEMA;
        }       break;
        case SQL_SET:

Index: sql_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_parser.mx,v
retrieving revision 1.242
retrieving revision 1.243
diff -u -d -r1.242 -r1.243
--- sql_parser.mx       28 Apr 2007 11:19:55 -0000      1.242
+++ sql_parser.mx       1 May 2007 22:03:09 -0000       1.243
@@ -51,6 +51,7 @@
        SQL_DROP_USER,
        SQL_DROP_TYPE,
        SQL_DROP_FUNC,
+       SQL_DROP_PROC,
        SQL_DROP_SEQ,
        SQL_DROP_TRIGGER,
        SQL_ALTER_TABLE,
@@ -1719,7 +1720,7 @@
                        { dlist *f = L();
                                append_list(f, $3);
                                append_list(f, $5);
-                               append_symbol(f, NULL);   /* no result */
+                               append_symbol(f, NULL); /* no result */
                                append_string(f, NULL); /* no mil-impl */
                                append_list(f, $7);
                          $$ = _symbol_create_list( SQL_CREATE_FUNC, f ); }
@@ -2130,6 +2131,13 @@
          append_list(l, $4 );
          append_int(l, $5 );
          $$ = _symbol_create_list( SQL_DROP_FUNC, l ); }
+ | DROP PROCEDURE qname opt_typelist drop_action
+       { dlist *l = L();
+         append_list(l, $3 );
+         append_int(l, 0 );
+         append_list(l, $4 );
+         append_int(l, $5 );
+         $$ = _symbol_create_list( SQL_DROP_PROC, l ); }
  | DROP ALL FUNCTION qname drop_action
        { dlist *l = L();
          append_list(l, $4 );
@@ -2137,6 +2145,13 @@
          append_list(l, NULL );
          append_int(l, $5 );
          $$ = _symbol_create_list( SQL_DROP_FUNC, l ); }
+ | DROP ALL PROCEDURE qname drop_action
+       { dlist *l = L();
+         append_list(l, $4 );
+         append_int(l, 1 );
+         append_list(l, NULL );
+         append_int(l, $5 );
+         $$ = _symbol_create_list( SQL_DROP_PROC, l ); }
  |  DROP VIEW qname drop_action
        { dlist *l = L();
          append_list(l, $3 );
@@ -4293,6 +4308,7 @@
        SQL(DROP_USER);
        SQL(DROP_TYPE);
        SQL(DROP_FUNC);
+       SQL(DROP_PROC);
        SQL(DROP_SEQ);
        SQL(DROP_TRIGGER);
        SQL(ALTER_TABLE);

Index: sql_semantic.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_semantic.mx,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- sql_semantic.mx     1 Apr 2007 22:08:57 -0000       1.161
+++ sql_semantic.mx     1 May 2007 22:03:10 -0000       1.162
@@ -1090,6 +1090,7 @@
 
        case SQL_CREATE_FUNC:
        case SQL_DROP_FUNC:
+       case SQL_DROP_PROC:
        case SQL_DECLARE:
        case SQL_SET:
                return psm(sql, s);

Index: sql_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_select.mx,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -d -r1.184 -r1.185
--- sql_select.mx       27 Apr 2007 07:27:31 -0000      1.184
+++ sql_select.mx       1 May 2007 22:03:10 -0000       1.185
@@ -179,7 +179,7 @@
                                temp_table = stack_find_view(sql, tname);
                        }
                }
-               if (!t && !temp_table) {
+               if (!t && (!temp_table || temp_table->type != st_list)) {
                        (void) sql_error(sql, 02, "SELECT: no such table '%s'", 
tname);
                        return NULL;
                } else if (!temp_table && !table_privs(sql, t, PRIV_SELECT)) {
@@ -204,6 +204,7 @@
        default:
                return query_exp_optname(sql, scp, tableref);
        }
+       return NULL;
 }
 
 stmt *


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to