[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - connectivity/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Nov 5 10:19:48 UTC 2018
connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx | 56 +++++-----
1 file changed, 32 insertions(+), 24 deletions(-)
New commits:
commit 0e4d2b85f266fc5fc09a4331efb2bb12332397c9
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Wed Oct 31 15:00:09 2018 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Nov 5 11:19:08 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>
Reviewed-on: https://gerrit.libreoffice.org/62802
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
index 468de04ee191..78e6337bb76d 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
@@ -703,31 +703,30 @@ Reference<XResultSet> SAL_CALL ODatabaseMetaData::getColumnPrivileges(
}
Reference<XResultSet> SAL_CALL ODatabaseMetaData::getColumns(const Any& /*catalog*/,
- const rtl::OUString& /*schemaPattern*/,
- const rtl::OUString& tableNamePattern,
- const rtl::OUString& columnNamePattern)
+ const OUString& schemaPattern,
+ const OUString& tableNamePattern,
+ const OUString& columnNamePattern)
{
- rtl::OUStringBuffer queryBuf("SELECT TABLE_CATALOG AS TABLE_CAT, " // 1
- "TABLE_SCHEMA AS TABLE_SCHEM, " // 2
- "TABLE_NAME, " // 3
- "COLUMN_NAME, " // 4
- "DATA_TYPE, " // 5
- // TYPE_NAME missing
- "CHARACTER_MAXIMUM_LENGTH, " // 6
- "NUMERIC_PRECISION, " // 7
- // buffer length missing
- "NUMERIC_SCALE AS DECIMAL_DIGITS, " // 8
- // NUM_PREC_RADIX missing
- // NULLABLE missing
- "COLUMN_COMMENT AS REMARKS, " // 9
- "COLUMN_DEFAULT AS COLUMN_DEF," // 10
- "CHARACTER_OCTET_LENGTH, " // 11
- "ORDINAL_POSITION, " // 12
- "IS_NULLABLE, " // 13
- "COLUMN_TYPE " // 14
- "FROM INFORMATION_SCHEMA.COLUMNS "
- "WHERE (1 = 1) ");
-
+ OUStringBuffer queryBuf("SELECT TABLE_CATALOG, " // 1
+ "TABLE_SCHEMA, " // 2
+ "TABLE_NAME, " // 3
+ "COLUMN_NAME, " // 4
+ "DATA_TYPE, " // 5
+ // TYPE_NAME missing
+ "CHARACTER_MAXIMUM_LENGTH, " // 6
+ "NUMERIC_PRECISION, " // 7
+ // buffer length missing
+ "NUMERIC_SCALE AS DECIMAL_DIGITS, " // 8
+ // NUM_PREC_RADIX missing
+ // NULLABLE missing
+ "COLUMN_COMMENT AS REMARKS, " // 9
+ "COLUMN_DEFAULT AS COLUMN_DEF," // 10
+ "CHARACTER_OCTET_LENGTH, " // 11
+ "ORDINAL_POSITION, " // 12
+ "IS_NULLABLE, " // 13
+ "COLUMN_TYPE " // 14
+ "FROM INFORMATION_SCHEMA.COLUMNS "
+ "WHERE (1 = 1) ");
if (!tableNamePattern.isEmpty())
{
rtl::OUString sAppend;
@@ -737,6 +736,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 (schemaPattern.match("%"))
+ sAppend = "AND TABLE_SCHEMA LIKE '%' ";
+ else
+ sAppend = "AND TABLE_SCHEMA = '%' ";
+ queryBuf.append(sAppend.replaceAll("%", schemaPattern));
+ }
if (!columnNamePattern.isEmpty())
{
rtl::OUString sAppend;
More information about the Libreoffice-commits
mailing list