On 8/11/2010 11:00 PM, Heejin Ju wrote:
>
> void
> DBDriver::disconnect()
> {
> if (is_connected_) {
> mysql_close(&mysql_);
> memset(&mysql_, 0, sizeof(mysql_));
> is_connected_ = false;
> error_message_.clear();
>
> // added code begin
> pending_options_ = applied_options_;
> applied_options_.clear();
> // added code end
> }
> }
It's not clear to me exactly what you're trying to do here. My guess is
that you want MySQL++ to automatically reapply previously-set connection
options when bouncing the connection. If so, I think MySQL++ is already
doing the right thing, and that your change can cause problems.
An explicit Connection::disconnect() followed by a connect() call on the
same object doesn't always indicate a reconnect to the same server, with
the same parameters. I'd guess that most of the time, code that does
this is trying to connect to a different server, or at least renegotiate
a different type of connection to the same server. I don't see why we'd
want to restrict this call pattern in MySQL++ so you always get the same
options on the new connection. The new connection might need different
options.
Furthermore, the way the library currently works doesn't prevent you
from reapplying the options yourself. You don't need MySQL++ to change
for this.
It might be nice to have DBDriver::reconnect() (wrapped in Connection),
which disconnects, re-enqueues all the options, then connects. My main
objection to doing that is that I don't see where you'd actually use it.
If you just need the connection to be automatically reestablished if
it drops for some reason, MySQL++ already provides ReconnectOption. So,
I'd need a use case where ReconnectOption isn't sufficient to justify
adding this method.