Thanks, I'll consider the sub query solution. // Nicklas
It's actual safe enough for my user case using the MySQL InnoDB engine, and default transaction isolation level. CREATE TABLE report.... S1 begin; S2 begin; S1 select coalesce(max(r.sequence) + 1, 1) from reports r where r.report_id = 1 for update; -> 1 S2 select coalesce(max(r.sequence) + 1, 1) from reports r where r.report_id = 1 for update -> 1 S1 insert into reports VALUES(1, 1 (the derived value)); S2 insert into reports VALUES(1, 1 (the derived value)); -> Deadlock found when trying to get lock; try restarting transaction -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
