Skip to content

Commit 2e1a4d5

Browse files
committed
Bug#30487665: Fix OPT_MULTI_HOST=false
Put OPT_MULTI_HOST on same place as other options.
1 parent 97f2bb7 commit 2e1a4d5

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

driver/mysql_connection.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ void MySQL_Connection::init(ConnectOptionsMap & properties)
561561
bool opt_reconnect = false;
562562
int client_exp_pwd = false;
563563
bool opt_dns_srv = false;
564+
bool opt_multi_host = false;
564565
#if MYCPPCONN_STATIC_MYSQL_VERSION_ID < 80000
565566
bool secure_auth= true;
566567
#endif
@@ -806,12 +807,22 @@ void MySQL_Connection::init(ConnectOptionsMap & properties)
806807
try {
807808
p_b = (it->second).get<bool>();
808809
} catch (sql::InvalidArgumentException&) {
809-
throw sql::InvalidArgumentException("Wrong type passed for OPT_DNS_SRV expected bool");
810+
throw sql::InvalidArgumentException("Wrong type passed for OPT_DNS_SRV, expected bool");
810811
}
811812
if (!(p_b)) {
812813
throw sql::InvalidArgumentException("No bool value passed for OPT_DNS_SRV");
813814
}
814815
opt_dns_srv = *p_b;
816+
} else if (!it->first.compare("OPT_MULTI_HOST")) {
817+
try {
818+
p_b = (it->second).get<bool>();
819+
} catch (sql::InvalidArgumentException&) {
820+
throw sql::InvalidArgumentException("Wrong type passed for OPT_MULTI_HOST, expected bool");
821+
}
822+
if (!(p_b)) {
823+
throw sql::InvalidArgumentException("No bool value passed for OPT_MULTI_HOST");
824+
}
825+
opt_multi_host = *p_b;
815826
} else if (!it->first.compare("OPT_CHARSET_NAME")) {
816827
try {
817828
p_s = (it->second).get< sql::SQLString >();
@@ -989,15 +1000,6 @@ void MySQL_Connection::init(ConnectOptionsMap & properties)
9891000
PROCESS_CONN_OPTION(int, intOptions);
9901001
}
9911002

992-
bool opt_multi_host = false;
993-
it = properties.find("OPT_MULTI_HOST");
994-
try {
995-
if(it != properties.end())
996-
opt_multi_host = it->second.get<bool>();
997-
} catch (sql::InvalidArgumentException&) {
998-
throw sql::InvalidArgumentException("Wrong type passed for OPT_MULTI_HOST, expected bool");
999-
}
1000-
10011003
if(!opt_multi_host && uri.size() > 1)
10021004
throw sql::InvalidArgumentException("Missing option OPT_MULTI_HOST = true");
10031005

0 commit comments

Comments
 (0)