Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3912/src/server

Modified Files:
        sql_schema.mx 
Log Message:
propagated changes of Sunday Jul 13 2008 - Monday Jul 14 2008
from the SQL_2-24 branch to the development trunk

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008/07/13 - nielsnes: src/server/sql_schema.mx,1.140.2.2
fix bug in handling references (old/new values) in triggers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: sql_schema.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_schema.mx,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- sql_schema.mx       5 Jun 2008 09:23:23 -0000       1.141
+++ sql_schema.mx       14 Jul 2008 07:57:30 -0000      1.142
@@ -26,9 +26,10 @@
 #include <stdarg.h>
 #include <sql_list.h>
 #include "sql_symbol.h"
+#include "sql_scope.h"
 #include "sql_statement.h"
 
-extern stmt *schemas(mvc *sql, symbol *sym);
+extern stmt *schemas(mvc *sql, scope *scp, symbol *sym);
 extern stmt *sql_create_table(mvc *sql, sql_schema *ss, int temp, dlist 
*qname, symbol *table_elements_or_subquery, int commit_action);
 
 #endif /*_SQL_SCHEMA_H_*/
@@ -38,7 +39,6 @@
 #include "sql_config.h"
 #include "sql_schema.h"
 #include "sql_parser.h"
-#include "sql_scope.h"
 #include "sql_updates.h"
 #include "sql_select.h"
 #include "sql_semantic.h"
@@ -519,11 +519,10 @@
 }
 
 static stmt *
-create_trigger(mvc *sql, dlist *qname, int time, symbol *trigger_event, 
+create_trigger(mvc *sql, scope *scp, dlist *qname, int time, symbol 
*trigger_event, 
        char *table_name, dlist *opt_ref, dlist *triggered_action)
 {
        stmt *sq = NULL;
-       scope *scp;
        sql_trigger *trigger;
        char *tname = qname_table(qname);
        sql_schema *ss = cur_schema(sql);
@@ -567,8 +566,17 @@
                trigger = mvc_create_trigger(sql, t, tname, time, orientation, 
                        event, old_name, new_name, condition, q);
        }
-       scp = scope_open(NULL);
+       if (!instantiate) {
+               scp = scope_open(NULL);
+               /* we need to add the old and new tables */
+               if (new_name)
+                       scope_add_table_columns(sql, scp, t, new_name, 0);
+               if (old_name)
+                       scope_add_table_columns(sql, scp, t, old_name, 0);
+       }
        sq = sequential_block(sql, scp, NULL, stmts, NULL, 1);
+       if (!instantiate)
+               scope_close(scp);
        
        if (sq && !instantiate) {
                list *col_l = stmt_list_dependencies(sq, COLUMN_DEPENDENCY);
@@ -585,7 +593,6 @@
                stmt_destroy(sq);
                sq = stmt_none();
        }
-       scope_close(scp);
        
        /* todo trigger_columns */
        (void)columns;
@@ -1841,7 +1848,7 @@
 }
 
 stmt *
-schemas(mvc *sql, symbol *s)
+schemas(mvc *sql, scope *scp, symbol *s)
 {
        stmt *ret = NULL;
 
@@ -2029,7 +2036,7 @@
        {
                dlist *l = s->data.lval;
 
-               ret = create_trigger(sql, l->h->data.lval, 
l->h->next->data.ival, l->h->next->next->data.sym, 
l->h->next->next->next->data.sval, l->h->next->next->next->next->data.lval, 
l->h->next->next->next->next->next->data.lval);
+               ret = create_trigger(sql, scp, l->h->data.lval, 
l->h->next->data.ival, l->h->next->next->data.sym, 
l->h->next->next->next->data.sval, l->h->next->next->next->next->data.lval, 
l->h->next->next->next->next->next->data.lval);
                sql->type = Q_SCHEMA;
        }
                break;


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to