summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Hałasa <khalasa@piap.pl>2021-12-29 11:37:26 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-01-04 11:58:59 +0100
commit0c5e0dcd19403f967bc1ae46ebb8649b27b29b86 (patch)
tree5905b9676a7ab3b6f7e06b76f53794a18a1d5532
parente57376c4ccf40bac3c284bd9a04000f0fd5ed360 (diff)
tdf#134982: use the right protocol for Mysql/Mariadb
Thank you Krzysztof Hałasa for the patch! Change-Id: Ib7532a716b7e0fa73f309e0a4f9af9e663e0d3df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127673 Reviewed-by: Lionel Mamane <lionel@mamane.lu> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Tested-by: Jenkins (cherry picked from commit 0143ec4d3d56eeee7edf16371c1d3c3981890b71) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127786 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_connection.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx b/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx
index 4cf9e916f3df..4d11c893eb13 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx
@@ -73,9 +73,6 @@ void OConnection::construct(const OUString& url, const Sequence<PropertyValue>&
mysql_library_init(0, nullptr, nullptr);
mysql_init(&m_mysql);
- // use TCP as connection
- mysql_protocol_type protocol = MYSQL_PROTOCOL_TCP;
- mysql_options(&m_mysql, MYSQL_OPT_PROTOCOL, &protocol);
OString charset_name{ "utf8mb4" };
mysql_options(&m_mysql, MYSQL_SET_CHARSET_NAME, charset_name.getStr());
@@ -164,15 +161,22 @@ void OConnection::construct(const OUString& url, const Sequence<PropertyValue>&
OString pass_str = OUStringToOString(aPass, m_settings.encoding);
OString schema_str = OUStringToOString(aDbName, m_settings.encoding);
OString socket_str;
+
+ // use TCP as connection by default
+ mysql_protocol_type protocol = MYSQL_PROTOCOL_TCP;
if (unixSocketPassed)
{
socket_str = OUStringToOString(sUnixSocket, m_settings.encoding);
+ protocol = MYSQL_PROTOCOL_SOCKET;
}
else if (namedPipePassed)
{
socket_str = OUStringToOString(sNamedPipe, m_settings.encoding);
+ protocol = MYSQL_PROTOCOL_PIPE;
}
+ mysql_options(&m_mysql, MYSQL_OPT_PROTOCOL, &protocol);
+
// flags can also be passed as last parameter
if (!mysql_real_connect(&m_mysql, host_str.getStr(), user_str.getStr(), pass_str.getStr(),
schema_str.getStr(), nPort, socket_str.getStr(),