mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 09:24:55 +02:00
add fail-readonly connection string parameter
This commit is contained in:
parent
8bf5fceaaf
commit
506049e360
@ -47,7 +47,7 @@ public:
|
||||
/// Connection string format:
|
||||
/// <str> == <assignment> | <assignment> ';' <str>
|
||||
/// <assignment> == <name> '=' <value>
|
||||
/// <name> == 'host' | 'port' | 'user' | 'password' | 'db' | 'compress' | 'auto-reconnect' | 'reset'
|
||||
/// <name> == 'host' | 'port' | 'user' | 'password' | 'db' | 'compress' | 'auto-reconnect' | 'reset' | 'fail-readonly'
|
||||
/// <value> == [~;]*
|
||||
///
|
||||
/// The following settings are supported:
|
||||
@ -61,6 +61,9 @@ public:
|
||||
/// - character-set: connection character set (default: utf8)
|
||||
/// - reset: reset connection when returned to SessionPool by calling
|
||||
/// mysql_reset_connection().
|
||||
/// - fail-readonly: if set to true, the session will fail
|
||||
/// if the database becomes read-only. This corresponds to
|
||||
/// setFailIfInnoReadOnly(true).
|
||||
///
|
||||
/// Warning: Due to a bug in MySQL, resetting the connection with mysql_reset_connection()
|
||||
/// could change the character encoding used for the connection. Therefore the
|
||||
|
@ -92,6 +92,7 @@ void SessionImpl::open(const std::string& connect)
|
||||
options["secure-auth"] = "";
|
||||
options["character-set"] = "utf8";
|
||||
options["reset"] = "";
|
||||
options["fail-readonly"] = "";
|
||||
|
||||
const std::string& connString = connectionString();
|
||||
for (std::string::const_iterator start = connString.begin();;)
|
||||
@ -153,6 +154,13 @@ void SessionImpl::open(const std::string& connect)
|
||||
else if (!options["reset"].empty())
|
||||
throw MySQLException("create session: specify correct reset option (true or false)");
|
||||
|
||||
if (options["fail-readonly"] == "true")
|
||||
_failIfInnoReadOnly = true;
|
||||
else if (options["fail-readonly"] == "false")
|
||||
_failIfInnoReadOnly = false;
|
||||
else if (!options["fail-readonly"].empty())
|
||||
throw MySQLException("create session: specify correct fail-readonly option (true or false)");
|
||||
|
||||
// Real connect
|
||||
_handle.connect(options["host"].c_str(),
|
||||
options["user"].c_str(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user