Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16:/tmp/cvs-serv17492
Modified Files:
sql_parser.mx sql_psm.mx sql_semantic.mx
Log Message:
Changes to support CALL inside procedures and function bodies.
It is also possible to call as a normal statement, for example:
create procedure p1(id)
begin
insert into t1 values(id);
end;
create procedure p1()
begin
declare id int;
set id = 0;
call p1(id);
end;
call p1();
The end result is the insertion of value 1 into the table t1.
Index: sql_psm.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_psm.mx,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- sql_psm.mx 4 May 2007 11:25:32 -0000 1.40
+++ sql_psm.mx 4 May 2007 14:21:46 -0000 1.41
@@ -42,6 +42,16 @@
#include "sql_semantic.h"
#include "sql_privileges.h"
+
+stmt*
+psm_call(mvc * sql, scope *scp, symbol *se)
+{
+ stmt *res = NULL;
+ exp_kind ek = {type_value, card_value, FALSE};
+ res = sql_value_exp(sql, scp, se, NULL, NULL, sql_sel, ek);
+ return res;
+}
+
/* SET variable = value */
static stmt *
@@ -390,6 +400,9 @@
case SQL_CASE:
res = psm_case(sql, scp, restype, s->data.lval->h,
is_func);
break;
+ case SQL_CALL:
+ res = psm_call(sql, scp, s->data.sym);
+ break;
case SQL_RETURN:
/*If it is not a function it cannot have a return
statement*/
if (!is_func)
@@ -782,6 +795,10 @@
ret = psm_declare(sql, NULL, s->data.lval->h);
sql->type = Q_UPDATE;
break;
+ case SQL_CALL:
+ ret = psm_call(sql, NULL, s->data.sym);
+ sql->type = Q_UPDATE;
+ break;
default:
return sql_error(sql, 01, "schema statement unknown
symbol(%ld)->token = %s", (long) s, token2string(s->token));
}
Index: sql_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_parser.mx,v
retrieving revision 1.244
retrieving revision 1.245
diff -u -d -r1.244 -r1.245
--- sql_parser.mx 3 May 2007 23:34:58 -0000 1.244
+++ sql_parser.mx 4 May 2007 14:21:46 -0000 1.245
@@ -63,6 +63,7 @@
SQL_DROP_DEFAULT,
SQL_DECLARE,
SQL_SET,
+ SQL_CALL,
SQL_PREP,
SQL_NAME,
SQL_USER,
@@ -296,6 +297,7 @@
control_statement
select_statement_single_row
call_statement
+ call_procedure_statement
routine_invocation
return_statement
return_value
@@ -716,6 +718,7 @@
| alter_statement
| declare_statement
| set_statement
+ | call_procedure_statement
;
declare_statement:
@@ -1790,7 +1793,8 @@
;
control_statement:
- call_statement
+ call_procedure_statement
+ | call_statement
| while_statement
| if_statement
| case_statement
@@ -1810,6 +1814,10 @@
CALL routine_invocation { $$ = $2; }
;
+call_procedure_statement:
+ CALL func_ref {$$ = _symbol_create_symbol(SQL_CALL,
$2);}
+ ;
+
routine_invocation:
routine_name '(' argument_list ')'
{ dlist *l = L();
@@ -1822,7 +1830,8 @@
routine_name: qname ;
argument_list:
- scalar_exp { $$ = append_symbol( L(), $1); }
+ /*empty*/ {$$ = L();}
+ | scalar_exp { $$ = append_symbol( L(), $1); }
| argument_list ',' scalar_exp
{ $$ = append_symbol( $1, $3); }
;
Index: sql_semantic.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_semantic.mx,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- sql_semantic.mx 3 May 2007 23:35:32 -0000 1.163
+++ sql_semantic.mx 4 May 2007 14:21:47 -0000 1.164
@@ -1093,6 +1093,7 @@
case SQL_DROP_FUNC:
case SQL_DROP_PROC:
case SQL_DECLARE:
+ case SQL_CALL:
case SQL_SET:
return psm(sql, s);
-------------------------------------------------------------------------
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