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

Modified Files:
        sql_updates.mx 
Log Message:
The foreign key is only checked when the action mode is RESTRICT.
Id's already in the action list can not be updated again.



Index: sql_updates.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_updates.mx,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- sql_updates.mx      18 Apr 2007 13:34:05 -0000      1.114
+++ sql_updates.mx      18 Apr 2007 16:21:53 -0000      1.115
@@ -844,10 +844,11 @@
                ckeys = update_check_ukey(sql, updates, k, idx_updates, updcol);
                sql_update_ukey(sql, schema, updates, k, updcol, l);
                list_prepend(l, ckeys);
-       } else {                /* foreign keys */
-               ckeys = update_check_fkey(sql, updates, k, idx_updates, updcol);
-               list_prepend(l, ckeys);
-       }
+       } else 
+               if (((sql_fkey*)k)->on_update == ACT_RESTRICT) {                
/* foreign keys */
+                       ckeys = update_check_fkey(sql, updates, k, idx_updates, 
updcol);
+                       list_prepend(l, ckeys);
+               }
 }
 
 static stmt *
@@ -963,18 +964,16 @@
                        is = join_idx_update(i, updates, updcol);
                }
                if (i->key) {
-                       if (!sql->cascade_action) {
-                               sql->cascade_action = list_create((fdestroy) 
NULL);
-                       } else {
-                               if (sql->cascade_action && 
!list_find_id(sql->cascade_action, i->key->base.id)) 
-                                       continue;
-                               else {
-                                       int id = i->key->base.id;
-                                       list_append(sql->cascade_action, &id);
-                               }
-                       }
+                       if (!(sql->cascade_action && 
list_find_id(sql->cascade_action, i->key->base.id))) {
+                               int *local_id = GDKmalloc(sizeof(int));
+                               if (!sql->cascade_action) 
+                                       sql->cascade_action = 
list_create((fdestroy) NULL);
+                               
+                               memcpy(local_id, &i->key->base.id, sizeof(int));
+                               list_append(sql->cascade_action, &local_id);
+                               sql_update_key(sql, schema, updates, i->key, 
is, updcol, l);
 
-                       sql_update_key(sql, schema, updates, i->key, is, 
updcol, l);
+                       }
 
                }
                if (is) 
@@ -1797,18 +1796,18 @@
        for (n = t->keys.set->h; n; n = n->next) {
                sql_key *k = n->data;
 
-               if ((k->type == pkey || k->type == ukey) && 
(!sql->cascade_action || !list_find_id(sql->cascade_action, k->base.id))) {
-                       int id = k->base.id;
+               if (k->type == pkey || k->type == ukey) {
+                       
+                       if (!(sql->cascade_action && 
list_find_id(sql->cascade_action, k->base.id))) {
+                               int *local_id = GDKmalloc(sizeof(int));
+                               if (!sql->cascade_action) 
+                                       sql->cascade_action = 
list_create((fdestroy) NULL);
+                               
+                               memcpy(local_id, &k->base.id, sizeof(int));
+                               list_append(sql->cascade_action, &local_id); 
+                               sql_delete_ukey(sql, schema, deletes, k, l);
 
-                       if ( sql->cascade_action) {
-                               list_append(sql->cascade_action, &id); 
                        }
-                       else {
-                               sql->cascade_action = list_create((fdestroy) 
NULL);
-                               list_append(sql->cascade_action, &id);
-                       }
-
-                       sql_delete_ukey(sql, schema, deletes, k, l);
 
                }
        }


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