[Libreoffice-commits] core.git: connectivity/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Nov 1 13:23:47 UTC 2018
connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx | 16 +++++++---
1 file changed, 12 insertions(+), 4 deletions(-)
New commits:
commit 39e0bbfdf77cf9653ec68ffcb4374d929838b2a8
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Wed Oct 31 15:00:09 2018 +0100
Commit: Tamás Bunth <btomi96 at gmail.com>
CommitDate: Thu Nov 1 14:23:20 2018 +0100
mysqlc: filter schema in getColumns
Filter schema in XDatabaseMetaData::getColumns so it would show correct
results in case there are more tables with the same name in different
schemas.
Change-Id: I8a986a43a8b049db3615d7ec2585ce68ebe3340e
Reviewed-on: https://gerrit.libreoffice.org/62696
Tested-by: Jenkins
Reviewed-by: Tamás Bunth <btomi96 at gmail.com>
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
index 507ce0b91e45..bd58d9cb1f5e 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
@@ -696,12 +696,12 @@ Reference<XResultSet>
}
Reference<XResultSet> SAL_CALL ODatabaseMetaData::getColumns(const Any& /*catalog*/,
- const OUString& /*schemaPattern*/,
+ const OUString& schemaPattern,
const OUString& tableNamePattern,
const OUString& columnNamePattern)
{
- OUStringBuffer queryBuf("SELECT TABLE_CATALOG AS TABLE_CAT, " // 1
- "TABLE_SCHEMA AS TABLE_SCHEM, " // 2
+ OUStringBuffer queryBuf("SELECT TABLE_CATALOG, " // 1
+ "TABLE_SCHEMA, " // 2
"TABLE_NAME, " // 3
"COLUMN_NAME, " // 4
"DATA_TYPE, " // 5
@@ -720,7 +720,6 @@ Reference<XResultSet> SAL_CALL ODatabaseMetaData::getColumns(const Any& /*catalo
"COLUMN_TYPE " // 14
"FROM INFORMATION_SCHEMA.COLUMNS "
"WHERE (1 = 1) ");
-
if (!tableNamePattern.isEmpty())
{
OUString sAppend;
@@ -730,6 +729,15 @@ Reference<XResultSet> SAL_CALL ODatabaseMetaData::getColumns(const Any& /*catalo
sAppend = "AND TABLE_NAME = '%' ";
queryBuf.append(sAppend.replaceAll("%", tableNamePattern));
}
+ if (!schemaPattern.isEmpty())
+ {
+ OUString sAppend;
+ if (tableNamePattern.match("%"))
+ sAppend = "AND TABLE_SCHEMA LIKE '%' ";
+ else
+ sAppend = "AND TABLE_SCHEMA = '%' ";
+ queryBuf.append(sAppend.replaceAll("%", schemaPattern));
+ }
if (!columnNamePattern.isEmpty())
{
OUString sAppend;
More information about the Libreoffice-commits
mailing list