mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 09:12:28 +02:00
make session reset optional and disable by default
This commit is contained in:
@@ -48,6 +48,7 @@ SessionImpl::SessionImpl(const std::string& connectionString, std::size_t loginT
|
||||
Poco::Data::AbstractSessionImpl<SessionImpl>(connectionString, loginTimeout),
|
||||
_connector("MySQL"),
|
||||
_handle(0),
|
||||
_reset(false),
|
||||
_connected(false),
|
||||
_inTransaction(false),
|
||||
_failIfInnoReadOnly(false),
|
||||
@@ -90,6 +91,7 @@ void SessionImpl::open(const std::string& connect)
|
||||
options["auto-reconnect"] = "";
|
||||
options["secure-auth"] = "";
|
||||
options["character-set"] = "utf8";
|
||||
options["reset"] = "";
|
||||
|
||||
const std::string& connString = connectionString();
|
||||
for (std::string::const_iterator start = connString.begin();;)
|
||||
@@ -123,14 +125,14 @@ void SessionImpl::open(const std::string& connect)
|
||||
else if (options["compress"] == "false")
|
||||
;
|
||||
else if (!options["compress"].empty())
|
||||
throw MySQLException("create session: specify correct compress option (true or false) or skip it");
|
||||
throw MySQLException("create session: specify correct compress option (true or false)");
|
||||
|
||||
if (options["auto-reconnect"] == "true")
|
||||
_handle.options(MYSQL_OPT_RECONNECT, true);
|
||||
else if (options["auto-reconnect"] == "false")
|
||||
_handle.options(MYSQL_OPT_RECONNECT, false);
|
||||
else if (!options["auto-reconnect"].empty())
|
||||
throw MySQLException("create session: specify correct auto-reconnect option (true or false) or skip it");
|
||||
throw MySQLException("create session: specify correct auto-reconnect option (true or false)");
|
||||
|
||||
#ifdef MYSQL_SECURE_AUTH
|
||||
if (options["secure-auth"] == "true")
|
||||
@@ -138,12 +140,19 @@ void SessionImpl::open(const std::string& connect)
|
||||
else if (options["secure-auth"] == "false")
|
||||
_handle.options(MYSQL_SECURE_AUTH, false);
|
||||
else if (!options["secure-auth"].empty())
|
||||
throw MySQLException("create session: specify correct secure-auth option (true or false) or skip it");
|
||||
throw MySQLException("create session: specify correct secure-auth option (true or false)");
|
||||
#endif
|
||||
|
||||
if (!options["character-set"].empty())
|
||||
_handle.options(MYSQL_SET_CHARSET_NAME, options["character-set"].c_str());
|
||||
|
||||
if (options["reset"] == "true")
|
||||
_reset = true;
|
||||
else if (options["reset"] == "false")
|
||||
_reset = false;
|
||||
else if (!options["reset"].empty())
|
||||
throw MySQLException("create session: specify correct reset option (true or false)");
|
||||
|
||||
// Real connect
|
||||
_handle.connect(options["host"].c_str(),
|
||||
options["user"].c_str(),
|
||||
@@ -264,8 +273,10 @@ bool SessionImpl::hasTransactionIsolation(Poco::UInt32 ti) const
|
||||
|
||||
void SessionImpl::reset()
|
||||
{
|
||||
if (_connected)
|
||||
if (_connected && _reset)
|
||||
{
|
||||
_handle.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user