Re: JDBC gripe list (the autocommit subthread)
От | Oliver Jowett |
---|---|
Тема | Re: JDBC gripe list (the autocommit subthread) |
Дата | |
Msg-id | AANLkTi=Bcs6ZoWfE9tbA0RpSVjD3j4G98rKXXPs1fUcE@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: JDBC gripe list (the autocommit subthread) (Quartz <quartz12h@yahoo.com>) |
Ответы |
Re: JDBC gripe list (the autocommit subthread)
Re: JDBC gripe list (the autocommit subthread) |
Список | pgsql-jdbc |
On 1 April 2011 10:34, Quartz <quartz12h@yahoo.com> wrote: > You have been defending all that long that most use the autocommit=false when using batches. Then they won't break....! > > Besides that's what release notes are for. And I dare say, if they expected a transaction when using a batch with autocommit=true,it about time they learn their mistake. JDBC api is a contract. Can't make exception for postgres. The JDBC spec says that the behavior of executeBatch() with autocommit=true is implementation defined, and specifically warns against using it with autocommit on. I don't see any problems with the driver's current behavior: (a) it would be quite a lot of extra work to wrap each statement in a separate transaction (we'd have to send explicit BEGIN/END around each statement execution; (b) the current behavior is consistent with how multiple statement execution works elsewhere in the driver, where if you execute "SELECT a; SELECT b" as a statement with autocommit=true then the two queries run in a single transaction; (c) usually batch updates are there for performance reasons, which is at odds with creating a separate transaction for each batched statement; (d) the current behavior *is* allowed by the specification. The problem is with your code relying on particular behavior of executeBatch() + autocommit, which the spec explicitly warns is implementation-defined behavior that you shouldn't rely on. Oliver
В списке pgsql-jdbc по дате отправления: