{"action":"created","issue":{"url":"https://api.github.com/repos/vert-x3/vertx-mysql-postgresql-service/issues/2","labels_url":"https://api.github.com/repos/vert-x3/vertx-mysql-postgresql-service/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/vert-x3/vertx-mysql-postgresql-service/issues/2/comments","events_url":"https://api.github.com/repos/vert-x3/vertx-mysql-postgresql-service/issues/2/events","html_url":"https://github.com/vert-x3/vertx-mysql-postgresql-service/issues/2","id":56749529,"number":2,"title":"setAutoCommit and transactions","user":{"login":"Narigo","id":1767865,"avatar_url":"https://avatars.githubusercontent.com/u/1767865?v=3","gravatar_id":"","url":"https://api.github.com/users/Narigo","html_url":"https://github.com/Narigo","followers_url":"https://api.github.com/users/Narigo/followers","following_url":"https://api.github.com/users/Narigo/following{/other_user}","gists_url":"https://api.github.com/users/Narigo/gists{/gist_id}","starred_url":"https://api.github.com/users/Narigo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Narigo/subscriptions","organizations_url":"https://api.github.com/users/Narigo/orgs","repos_url":"https://api.github.com/users/Narigo/repos","events_url":"https://api.github.com/users/Narigo/events{/privacy}","received_events_url":"https://api.github.com/users/Narigo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-05T23:58:48Z","updated_at":"2015-02-06T00:21:15Z","closed_at":null,"body":"There are a couple of cases that we need to look at, when providing and simulating the `setAutoCommit()` from JDBC with this driver. In PostgreSQL you don't really set auto commit on and off, you just begin and commit or rollback a transaction.\r\n\r\nFrom what I've learned from JDBC documentation is the following:\r\n\r\nIf `setAutoCommit` changes from `true` (default) to `false`, it will start a transaction.\r\nIf `setAutoCommit` changes from `false` to `true`, it will commit a transaction.\r\nIf you commit or rollback and have auto commit set to false, it will commit or rollback and start a new transaction immediately afterwards.\r\nIf you call setAutoCommit() and it doesn't change from the current setting, it will do nothing (= call the success callback immediately)\r\nIf you commit or rollback when auto commit is set to true, it will (most probably) fail due to a database error (you cannot commit/rollback when no transaction is running).\r\n\r\nFrom my point of view, this `setAutoCommit(boolean)` adds complexity for the user, which could be mitigated if we would just provide a method called `startTransaction`. The user can call it to begin a transaction. With `setAutoCommit()` we handle the stuff behind the users back: On a commit or rollback, we immediately start a new connection by issuing another command to the database.\r\n\r\nI'm also not sure yet, what to do when the user closes a connection. As it should be put back into the connection pool, I believe it should automatically call `setAutoCommit(false)` and then give the connection back to the pool. I'm not sure how to solve the problem if someone commits and then closes the connection: This would call the database twice with two commands: 1. begin new transaction and 2. commit the (empty) transaction.\r\n\r\nWDYT?"},"comment":{"url":"https://api.github.com/repos/vert-x3/vertx-mysql-postgresql-service/issues/comments/73158649","html_url":"https://github.com/vert-x3/vertx-mysql-postgresql-service/issues/2#issuecomment-73158649","issue_url":"https://api.github.com/repos/vert-x3/vertx-mysql-postgresql-service/issues/2","id":73158649,"user":{"login":"Narigo","id":1767865,"avatar_url":"https://avatars.githubusercontent.com/u/1767865?v=3","gravatar_id":"","url":"https://api.github.com/users/Narigo","html_url":"https://github.com/Narigo","followers_url":"https://api.github.com/users/Narigo/followers","following_url":"https://api.github.com/users/Narigo/following{/other_user}","gists_url":"https://api.github.com/users/Narigo/gists{/gist_id}","starred_url":"https://api.github.com/users/Narigo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Narigo/subscriptions","organizations_url":"https://api.github.com/users/Narigo/orgs","repos_url":"https://api.github.com/users/Narigo/repos","events_url":"https://api.github.com/users/Narigo/events{/privacy}","received_events_url":"https://api.github.com/users/Narigo/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T00:21:15Z","updated_at":"2015-02-06T00:21:15Z","body":"Updated the issue as I came on the create button while typing... if you got an email with a strange issue before, please have a look at it now on GitHub issues, thanks!"}}