[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - connectivity/source

Tamas Bunth (via logerrit) logerrit at kemper.freedesktop.org
Mon Sep 2 10:34:01 UTC 2019


 connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx |   16 ++++++++--
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit c4d5da753aaad2df86f64d328d3bb838146df6a9
Author:     Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Fri Aug 30 13:59:35 2019 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Mon Sep 2 12:33:21 2019 +0200

    mysqlc: Implement DatabaseMetadata::getUserName
    
    Change-Id: Id3518a049a55d64e7272d265f22e930881a70161
    Reviewed-on: https://gerrit.libreoffice.org/78296
    Tested-by: Jenkins
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>
    (cherry picked from commit f5c09ac04860f779532fe83f8ebce237d46eb1f5)
    Reviewed-on: https://gerrit.libreoffice.org/78386
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
index f04b8928714b..a433c9d81bea 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
@@ -361,9 +361,19 @@ OUString SAL_CALL ODatabaseMetaData::getURL()
 
 OUString SAL_CALL ODatabaseMetaData::getUserName()
 {
-    // TODO execute "SELECT USER()"
-    SAL_WARN("connectivity.mysqlc", "method not implemented");
-    return OUString();
+    Reference<XStatement> statement = m_rConnection.createStatement();
+    Reference<XResultSet> rs = statement->executeQuery("select user()");
+    Reference<XRow> xRow(rs, UNO_QUERY_THROW);
+    rs->next(); // the first and only result
+    // e.g. root at localhost
+    OUString userWithConnection = xRow->getString(1);
+    sal_Int32 nIndexOfAt = userWithConnection.indexOf("@");
+    if (nIndexOfAt > 0)
+    {
+        OUString user = userWithConnection.copy(0, nIndexOfAt);
+        return user;
+    }
+    return userWithConnection;
 }
 
 OUString SAL_CALL ODatabaseMetaData::getDriverName() { return OUString("MySQL Connector/OO.org"); }


More information about the Libreoffice-commits mailing list