Hi,
org.h2.command.dml.Merge in line 164-167 (merge method)
turns DUPLICATE_KEY_1 error into CONCURRENT_UPDATE_1 error.
if (e.getErrorCode() == ErrorCode.DUPLICATE_KEY_1) {
// concurrent merge or insert
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, table.getName());
}
This can not be correct in all cases since a merge operation can result
in UNIQUE constraint
violation even though the merge is a valid one and there are not
concurrent updates going on.
Test case:
CREATE TABLE T1 (
C1 INT PRIMARY KEY,
C2 INT,
C3 INT,
UNIQUE(C2,C3)
);
INSERT INTO T1 VALUES(1,1,1);
MERGE INTO T1 VALUES(2,1,1);
Last statement throws:
MERGE INTO T1 VALUES(2,1,1) [50200-155]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:156)
at org.h2.command.Command.filterConcurrentUpdate(Command.java:257)
at org.h2.command.Command.executeUpdate(Command.java:214)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:300)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:137)
at java.lang.Thread.run(Thread.java:636)
Caused by: org.h2.jdbc.JdbcSQLException: Concurrent update in table
"T1": another transaction has updated or deleted the same row [90131-155]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.dml.Merge.merge(Merge.java:166)
at org.h2.command.dml.Merge.update(Merge.java:104)
at org.h2.command.CommandContainer.update(CommandContainer.java:71)
at org.h2.command.Command.executeUpdate(Command.java:212)
... 3 more
at org.h2.engine.SessionRemote.done(SessionRemote.java:538)
at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:183)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:177)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:152)
at org.h2.server.web.WebApp.getResult(WebApp.java:1304)
at org.h2.server.web.WebApp.query(WebApp.java:994)
at org.h2.server.web.WebApp$1.next(WebApp.java:957)
at org.h2.server.web.WebApp$1.next(WebApp.java:946)
at org.h2.server.web.WebThread.process(WebThread.java:166)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Thread.java:636)
This is clearly not the case.
- 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
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.