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

Modified Files:
      Tag: SQL_2-24
        sql_schema.mx sql_semantic.mx sql_updates.mx 
Log Message:
fix bug in handling references (old/new values) in triggers


U sql_semantic.mx
Index: sql_semantic.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_semantic.mx,v
retrieving revision 1.181.2.1
retrieving revision 1.181.2.2
diff -u -d -r1.181.2.1 -r1.181.2.2
--- sql_semantic.mx     4 Jun 2008 20:19:17 -0000       1.181.2.1
+++ sql_semantic.mx     13 Jul 2008 18:27:10 -0000      1.181.2.2
@@ -1130,7 +1130,7 @@
        case SQL_CONNECT:
        case SQL_DISCONNECT:
        {
-               res = schemas(sql, s);
+               res = schemas(sql, scp, s);
                break;
        }
        case SQL_CREATE_SEQ:

U sql_schema.mx
Index: sql_schema.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_schema.mx,v
retrieving revision 1.140.2.1
retrieving revision 1.140.2.2
diff -u -d -r1.140.2.1 -r1.140.2.2
--- sql_schema.mx       4 Jun 2008 20:19:16 -0000       1.140.2.1
+++ sql_schema.mx       13 Jul 2008 18:27:10 -0000      1.140.2.2
@@ -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;

U sql_updates.mx
Index: sql_updates.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_updates.mx,v
retrieving revision 1.138.2.2
retrieving revision 1.138.2.3
diff -u -d -r1.138.2.2 -r1.138.2.3
--- sql_updates.mx      17 Jun 2008 08:37:31 -0000      1.138.2.2
+++ sql_updates.mx      13 Jul 2008 18:27:10 -0000      1.138.2.3
@@ -1188,7 +1188,7 @@
 }
 
 static stmt *
-insert_into(mvc *sql, dlist *qname, dlist *columns, symbol *val_or_q)
+insert_into(mvc *sql, scope *scp, dlist *qname, dlist *columns, symbol 
*val_or_q)
 {
        int inscol = 0;
 
@@ -1257,7 +1257,7 @@
 
                                for (n = values->h, m = collist->h; n && m; n = 
n->next, m = m->next) {
                                        sql_column *c = m->data;
-                                       stmt *ins = insert_value(sql, NULL, c, 
n->data.sym);
+                                       stmt *ins = insert_value(sql, scp, c, 
n->data.sym);
 
                                        if (!ins) {
                                                cleanup_stmts(inserts, len);
@@ -1986,7 +1986,7 @@
        {
                dlist *l = s->data.lval;
 
-               ret = insert_into(sql, l->h->data.lval, l->h->next->data.lval, 
l->h->next->next->data.sym);
+               ret = insert_into(sql, scp, l->h->data.lval, 
l->h->next->data.lval, l->h->next->next->data.sym);
                sql->type = Q_UPDATE;
        }
                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