Hi, Check constraints are only checked when a row is added or modified, in the table where the constraint exists. Therefore, check constraints only operate on one table. I will document that.
Checking constraints across tables is not a feature I would like to support, because it can easily get very complicated and very very slow. I believe this limitation is reasonable. I think if you need a more complex solution, you can define constraints in the related table as well, but be aware constraints are checked immediately and not just at the end of a transaction. Regards, Thomas On Fri, Oct 26, 2012 at 6:55 PM, Rami Ojares <[email protected]> wrote: > Check constraint (and other constraints) are already added to Dabase as > DbObjects. > Eg. > AlterTableAddConstraint.java > line 241: db.addSchemaObject(session, constraint); > > But it is also added to table > line 243: table.addConstraint(**constraint); > > If it is defined for column it is associated with a Column in Parser > line 5261: column.addCheckConstraint(**session, expr); > > So basically my current idea would be to remove the check constraints from > table and column and keep them only in database. > > Let's continue with the Insert example. > Insert.java > line 142: table.fire(session, Trigger.INSERT, false); > Before that we could add something like > dbConstraints = session.getDatabase().**getAffectedConstraints(table, > <list_of_changed_columns>); > for(dbc : dbConstraints) { > dbc.checkExistingData(session)**; // Implementation in > ConstraintCheck.java needs to be modified because it assumes that it > operates only on single table > } > > All insight is much appreciated because I am still a bit overwhelmed by > all the code and it's mysterious ways. > (Parser must be the longest java file I have seen with 5379 lines :) > > > - Rami > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to h2-database+unsubscribe@** > googlegroups.com <h2-database%[email protected]>. > For more options, visit this group at http://groups.google.com/** > group/h2-database?hl=en <http://groups.google.com/group/h2-database?hl=en> > . > > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
