> So if someone would like to move the constraint check to the end of > transaction > one would need to create some kind of changeset caused by the transaction. > > The simple way to do it would be > List<Row> oldRows, List<Row> newRows > that would simply be a list of rows that have been somehow affected by > the transaction. > > These lists could be populated in the same place where the constraints > are now being checked. > > And then at commit time the constraints could be actually checked.
On long transactions or large data imports this can cause out of memory errors. Also the same row can be modified mutiple times in transaction so in these lists you will hold multiple versions of the same row. This is only simple problems I see but I think there will be more weird ones. Anyways just keep all changes in memory obviously is not very good idea. In my opinion here is needed to store only failed row keys, manage them (delete key if row was deleted from table or if this row was updated and constraint was satisfied, may be more complex things will be needed for referential constraints) and if on commit at least one failed row key is still here then transaction should be rolled back and exception thrown. > And for all you speed freaks this could actually increase speed because > now the constraints > are checked twice for every statement (before and after the statement). > Doing it at transaction boundary > would require running them only once :-) It is not true. Before statement called one part of constraints and after another part but not all constraints two times (see isBefore()). > Comments? > Should I give this a shot? I think it would be nice if you will implement this feature but please do more investigations before coding. regards, Sergi -- 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.
