diff options
author | Tamas Bunth <tamas.bunth@collabora.co.uk> | 2018-10-31 15:00:09 +0100 |
---|---|---|
committer | Tamás Bunth <btomi96@gmail.com> | 2018-11-01 14:23:20 +0100 |
commit | 39e0bbfdf77cf9653ec68ffcb4374d929838b2a8 (patch) | |
tree | 67c28ca0ad5fcffd505773df3282158ae3c7e98a /connectivity | |
parent | 4326fb3ef3ddd7c6f9d08ba96add4f4736503ceb (diff) |
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@gmail.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
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; |