connectivity/source/drivers/mysqlc/mysqlc_connection.cxx |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit 0c5e0dcd19403f967bc1ae46ebb8649b27b29b86
Author:     Krzysztof Hałasa <khal...@piap.pl>
AuthorDate: Wed Dec 29 11:37:26 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jan 4 11:58:59 2022 +0100

    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 <lio...@mamane.lu>
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>
    Tested-by: Jenkins
    (cherry picked from commit 0143ec4d3d56eeee7edf16371c1d3c3981890b71)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127786
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

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(),

Reply via email to