-
Notifications
You must be signed in to change notification settings - Fork 2
Feature request: add a dbResetConnection() generic #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What user defined variables are you thinking of? |
We stumbled upon this when we were trying to fix the encoding situation by running |
I skimmed the postgres and sqlite docs and I couldn't find methods to "reset" a connection. So I'm not sure how we'd solve this in general. We could implement a |
Hmmm, could postgres simply execute a RESET ALL query? sqlite does seem trickier, but this function does at least seem to keep track of the connection params... Could a meantime solution be:
In any case, I don't think this will become a major, major problem (at least for |
Would be great to get this in the next version of DBI |
We have something like this in the MonetDB driver where the parameters used for dbConnect are kept around in the connection to allow the creation of a secondary connection for checking the status of the currently running query (not ready for prime-time yet). But I would implement a default for this in DBI like this, the parameters to dbConnect are kept and dbConnect is re-executed. In my case, the internal state of the connection is kept in an environment allowing in-place modification, but in the generic case we could have dbResetConnection return the 'reset' connection so that a generic implementation is possible. e.g. |
Also, what about running transactions? Should dbResetConnection abort those or commit? |
@hannesmuehleisen that feels more like connection cloning, which is fine for local databases (because it's so fast) but might incur substantial performance penalties otherwise. (The broader context for this issue is the development of a package to manage a connection pool, where efficiently reseting a connection is quite important). |
@hannesmuehleisen dbResetConnection should definitely rollback transactions. The effect should be analogous to closing the connection and replacing it with a new one, just without the overhead of actually negotiating a new connection. |
@bborgesr: Is this still relevant? |
Closing because information is missing and no feedback has been provided. For related problems, please open a new issue and add a link to this issue. |
Sometimes it's useful to reset all user-defined variables back to their defaults in a DBIConnection (set using
SET
), instead of having to disconnect and fetch a brand new connection. This is particularly important in the context of a connection pool, for which we want to make sure that, when a connection is returned to the pool, its variables will be reset (so that when it's checkout again, it is as good as new).It seems that this would be very easy to do if DBI had a generic called
dbResetConnection()
or the like. Each driver would then have to implement the corresponding method for its connections, in order to be considered DBI-compliant. For example, in RMySQL, this could be implemented using MySQL'smysql_reset_connection()
.cc @hadley, @jcheng5
The text was updated successfully, but these errors were encountered: