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

Modified Files:
        sql_schema.mx 
Log Message:
propagated changes of Saturday Aug 02 2008 - Tuesday Aug 05 2008
from the SQL_2-24 branch to the development trunk

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008/08/02 - nielsnes: src/server/sql_schema.mx,1.140.2.4
fixed two problems related to null checking

1) when a column gets a 'not null' constraint the current content should be
checked. (see bug #1997030)

2) when we a column with 'not null' constraint but without default.
we should only dynamically check for 'not null' constraint violations.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: sql_schema.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_schema.mx,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- sql_schema.mx       21 Jul 2008 15:27:31 -0000      1.143
+++ sql_schema.mx       5 Aug 2008 09:01:45 -0000       1.144
@@ -1264,10 +1264,7 @@
                if (alter) {
                        atom *a = NULL;
 
-                       if (!cs->null && !cs->def) {
-                               return sql_error(sql, 02, "CREATE TABLE: column 
default value is NULL, but column has NOT NULL constraint\n");
-                       }
-                       if (cs->null && !cs->def) {
+                       if (!cs->def) {
                                a = atom_general(&cs->type, NULL, 0);
                                if (a)
                                        res = stmt_append_col(cs, 
stmt_const(stmt_bat(mvc_first_column(sql, t), stmt_basetable(t, t->base.name), 
RDONLY), stmt_atom(a)));
@@ -1517,7 +1514,21 @@
                if (!c) 
                        return sql_error(sql, 02, "column '%s' not found\n", 
cname);
                mvc_null(sql, c, null);
-               res = stmt_none();
+               if (alter && !c->null) {
+                       char *msg;
+                       sql_subaggr *cnt = sql_bind_aggr(sql->session->schema, 
"count", NULL);
+                       stmt *bt = stmt_basetable(c->t, c->t->base.name);
+                       stmt *cs = stmt_bat(c, bt, RDONLY);
+                       stmt *s = stmt_atom(atom_general(&c->type, NULL, 0));
+
+                       s = stmt_uselect(cs, s, cmp_equal);
+                       s = stmt_aggr(s, NULL, sql_dup_aggr(cnt), 1);
+                       msg = sql_message( "ALTER TABLE: NOT NULL constraint 
violated for column %s.%s", c->t->base.name, c->base.name);
+
+                       res = stmt_exception(s, msg, 00001);
+               } else {
+                       res = stmt_none();
+               }
        }
        break;
        case SQL_DROP_DEFAULT:


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to