summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2019-08-30 13:59:35 +0200
committerTamás Bunth <btomi96@gmail.com>2019-08-31 17:49:51 +0200
commitf5c09ac04860f779532fe83f8ebce237d46eb1f5 (patch)
treecced782b98aed91601509faeb2558fa8daacaedc /connectivity
parent9b2c9d25bdd9c763078557e809cfacb5d760ffec (diff)
mysqlc: Implement DatabaseMetadata::getUserName
Change-Id: Id3518a049a55d64e7272d265f22e930881a70161 Reviewed-on: https://gerrit.libreoffice.org/78296 Tested-by: Jenkins Reviewed-by: Tamás Bunth <btomi96@gmail.com>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx16
1 files changed, 13 insertions, 3 deletions
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
index bca56e119626..a57f10720104 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@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 "MySQL Connector/OO.org"; }