Update of /cvsroot/monetdb/sql/src/storage/bat
In directory sc8-pr-cvs16:/tmp/cvs-serv31503/bat

Modified Files:
        bat_store.mx sql_catalog.mx 
Log Message:
All the features supported for functions are now supported for procedures. 
However, procedure and functions differ in two aspects (well, maybe one):
Procedure do not have return type and no return statements in their 
runtime_body.

A new field to the struct sql_func was added to simply the distinguish between t
hem and also to help in the dependencies check.



Index: bat_store.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bat/bat_store.mx,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- bat_store.mx        28 Apr 2007 11:19:34 -0000      1.132
+++ bat_store.mx        3 May 2007 23:31:55 -0000       1.133
@@ -1310,6 +1310,7 @@
        t->sql = *(bit *) bun_find(func_sql, lid);
        t->aggr = *(bit *) bun_find(func_aggr, lid);
        t->res.type = NULL;
+       t->is_func = 0;
        t->s = s;
 
        args = BATselect(arg_func_id, (ptr) &t->base.id, (ptr) &t->base.id);
@@ -1331,6 +1332,7 @@
                        first = 0;
                        if (strcmp(a->name, "result") == 0) {
                                t -> res = a->type;
+                               t->is_func = 1;
                                arg_destroy(a);
                        } else {
                                list_append(t->ops, a);
@@ -3049,6 +3051,7 @@
        }
 
        f->s = s;
+       f->is_func = of->is_func;
        return f;
 }
 
@@ -4482,6 +4485,7 @@
                                case INDEX_DEPENDENCY :
                                                        sql_trans_drop_idx(tr, 
s, dep_id, DROP_CASCADE);
                                                        break;
+                               case PROC_DEPENDENCY :
                                case FUNC_DEPENDENCY :
                                                        sql_trans_drop_func(tr, 
s, dep_id, DROP_CASCADE);
                                                        break;
@@ -4746,23 +4750,25 @@
 {
        sql_schema *syss = find_sql_schema(tr, "sys");
        sql_table *sys_tab_func = find_sql_table(syss, "functions");
-       sql_table *sys_tab_args = find_sql_table(syss, "args");
        sql_column *sys_func_col = find_sql_column(sys_tab_func, "id");
-       sql_column *sys_args_col = find_sql_column(sys_tab_args, "func_id");
        ssize_t rid_func = column_find_row(tr, sys_func_col, &func->base.id, 
NULL);
-       ssize_t rid_args = column_find_row(tr, sys_args_col, &func->base.id, 
NULL);
+       if (func->aggr) {
+               sql_table *sys_tab_args = find_sql_table(syss, "args");
+               sql_column *sys_args_col = find_sql_column(sys_tab_args, 
"func_id");
+               ssize_t rid_args = column_find_row(tr, sys_args_col, 
&func->base.id, NULL);
+               assert(rid_args != -1);
+               table_delete(tr, sys_tab_args, rid_args);
+       }
 
        assert(rid_func != -1);
-       assert(rid_args != -1);
        table_delete(tr, sys_tab_func, rid_func);
-       table_delete(tr, sys_tab_args, rid_args);
 
        sql_trans_drop_dependencies(tr, func->base.id);
 
        tr->schema_updates ++;
 
        if (drop_action)
-               sql_trans_drop_all_dependencies(tr, syss, func->base.id, 
FUNC_DEPENDENCY);
+               sql_trans_drop_all_dependencies(tr, syss, func->base.id, 
func->is_func ? FUNC_DEPENDENCY : PROC_DEPENDENCY);
 }
 
 static void
@@ -4848,7 +4854,7 @@
 }
 
 sql_func *
-sql_trans_create_func(sql_trans *tr, sql_schema * s, char *func, list *args, 
sql_subtype *res, bit sql, bit aggr, char *mod, char *impl)
+sql_trans_create_func(sql_trans *tr, sql_schema * s, char *func, list *args, 
sql_subtype *res, bit sql, bit aggr, char *mod, char *impl, int is_func)
 {
        sql_func *t = NEW(sql_func);
        sql_table *sysfunc = find_sql_table(find_sql_schema(tr, "sys"), 
"functions");
@@ -4864,6 +4870,7 @@
        t->aggr = aggr;
        t->ops = list_dup(args, (fdup)&arg_dup);
        t->res.type = NULL;
+       t->is_func = is_func;
        if (res)
                t->res = *res;
        t->s = s;

Index: sql_catalog.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bat/sql_catalog.mx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- sql_catalog.mx      28 Apr 2007 11:19:34 -0000      1.21
+++ sql_catalog.mx      3 May 2007 23:31:56 -0000       1.22
@@ -286,7 +286,7 @@
 }
 
 list *
-find_all_sql_func(sql_schema * s, char *name)
+find_all_sql_func(sql_schema * s, char *name, int is_func)
 {
        list *l = s->funcs.set, *res = NULL;
        node *n = NULL;
@@ -294,9 +294,10 @@
         if (l)
                 for (n = l->h; n; n = n->next) {
                         sql_base *b = n->data;
+                        sql_func *f = n->data;
 
                         /* check if names match */
-                        if (name[0] == b->name[0] && strcmp(name, b->name) == 
0) {
+                        if (f->is_func == is_func && name[0] == b->name[0] && 
strcmp(name, b->name) == 0) {
                                if (!res)
                                        res = list_create((fdestroy) NULL);
                                list_append(res, n->data);


-------------------------------------------------------------------------
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