提交 2c82f14b 编写于 作者: S Serge Rider

Merge remote-tracking branch 'origin/devel' into devel

......@@ -966,7 +966,7 @@
<file type="jar" path="https://ftp.cubrid.org/CUBRID_Drivers/JDBC_Driver/JDBC-10.1.0.7663-cubrid.jar"/>
</driver>
<!-- Solr -->`
<!-- Solr -->
<driver
id="apache_solrj"
label="Solr"
......
......@@ -67,6 +67,7 @@ public class GenericDataSource extends JDBCDataSource implements DBPTermProvider
private List<GenericSchema> schemas;
private final GenericMetaModel metaModel;
private GenericObjectContainer structureContainer;
boolean catalogsFiltered;
private String queryGetActiveDB;
private String querySetActiveDB;
......@@ -486,55 +487,13 @@ public class GenericDataSource extends JDBCDataSource implements DBPTermProvider
try (JDBCSession session = DBUtils.openMetaSession(monitor, this, "Read generic metadata")) {
// Read metadata
JDBCDatabaseMetaData metaData = session.getMetaData();
boolean catalogsFiltered = false;
if (!omitCatalog) {
// Read catalogs
monitor.subTask("Extract catalogs");
monitor.worked(1);
final GenericMetaObject catalogObject = getMetaObject(GenericConstants.OBJECT_CATALOG);
final DBSObjectFilter catalogFilters = getContainer().getObjectFilter(GenericCatalog.class, null, false);
final List<String> catalogNames = new ArrayList<>();
try {
try (JDBCResultSet dbResult = metaData.getCatalogs()) {
int totalCatalogs = 0;
while (dbResult.next()) {
String catalogName = GenericUtils.safeGetString(catalogObject, dbResult, JDBCConstants.TABLE_CAT);
if (CommonUtils.isEmpty(catalogName)) {
// Some drivers uses TABLE_QUALIFIER instead of catalog
catalogName = GenericUtils.safeGetStringTrimmed(catalogObject, dbResult, JDBCConstants.TABLE_QUALIFIER);
if (CommonUtils.isEmpty(catalogName)) {
continue;
}
}
totalCatalogs++;
if (catalogFilters == null || catalogFilters.matches(catalogName)) {
catalogNames.add(catalogName);
monitor.subTask("Extract catalogs - " + catalogName);
} else {
catalogsFiltered = true;
}
if (monitor.isCanceled()) {
break;
}
}
if (totalCatalogs == 1 && omitSingleCatalog) {
// Just one catalog. Looks like DB2 or PostgreSQL
// Let's just skip it and use only schemas
// It's ok to use "%" instead of catalog name anyway
catalogNames.clear();
}
}
} catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
// Just skip it
log.debug("Catalog list not supported: " + e.getMessage());
} catch (Throwable e) {
if (metaModel.isCatalogsOptional()) {
// Error reading catalogs - just warn about it
log.warn("Can't read catalog list", e);
} else {
throw new DBException("Error reading catalog list", e);
}
}
final List<String> catalogNames = getCatalogsNames(monitor, metaData, catalogObject, catalogFilters);
if (!catalogNames.isEmpty() || catalogsFiltered) {
this.catalogs = new ArrayList<>();
for (String catalogName : catalogNames) {
......@@ -543,7 +502,6 @@ public class GenericDataSource extends JDBCDataSource implements DBPTermProvider
}
}
}
if (CommonUtils.isEmpty(catalogs) && !catalogsFiltered) {
// Catalogs not supported - try to read root schemas
monitor.subTask("Extract schemas");
......@@ -577,6 +535,52 @@ public class GenericDataSource extends JDBCDataSource implements DBPTermProvider
}
}
public List<String> getCatalogsNames(@NotNull DBRProgressMonitor monitor, @NotNull JDBCDatabaseMetaData metaData, GenericMetaObject catalogObject, @Nullable DBSObjectFilter catalogFilters) throws DBException {
final List<String> catalogNames = new ArrayList<>();
try {
try (JDBCResultSet dbResult = metaData.getCatalogs()) {
int totalCatalogs = 0;
while (dbResult.next()) {
String catalogName = GenericUtils.safeGetString(catalogObject, dbResult, JDBCConstants.TABLE_CAT);
if (CommonUtils.isEmpty(catalogName)) {
// Some drivers uses TABLE_QUALIFIER instead of catalog
catalogName = GenericUtils.safeGetStringTrimmed(catalogObject, dbResult, JDBCConstants.TABLE_QUALIFIER);
if (CommonUtils.isEmpty(catalogName)) {
continue;
}
}
totalCatalogs++;
if (catalogFilters == null || catalogFilters.matches(catalogName)) {
catalogNames.add(catalogName);
monitor.subTask("Extract catalogs - " + catalogName);
} else {
catalogsFiltered = true;
}
if (monitor.isCanceled()) {
break;
}
}
if (totalCatalogs == 1 && omitSingleCatalog) {
// Just one catalog. Looks like DB2 or PostgreSQL
// Let's just skip it and use only schemas
// It's ok to use "%" instead of catalog name anyway
catalogNames.clear();
}
}
} catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
// Just skip it
log.debug("Catalog list not supported: " + e.getMessage());
} catch (Throwable e) {
if (metaModel.isCatalogsOptional()) {
// Error reading catalogs - just warn about it
log.warn("Can't read catalog list", e);
} else {
throw new DBException("Error reading catalog list", e);
}
}
return catalogNames;
}
public boolean isOmitCatalog() {
return CommonUtils.getBoolean(getContainer().getDriver().getDriverParameter(GenericConstants.PARAM_OMIT_CATALOG), false);
}
......
......@@ -28,13 +28,20 @@ import org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCBasicDataTypeCache;
public class GenericDataTypeCache extends JDBCBasicDataTypeCache<GenericStructContainer, GenericDataType>
{
private static final boolean IGNORE_NUMERIC_TYPES = false;
public GenericDataTypeCache(GenericStructContainer owner) {
super(owner);
// Ignore abstract types. There can be multiple numeric types with the same name
// but different scale/precision properties
ignoredTypes.add("NUMBER");
ignoredTypes.add("NUMERIC");
if (IGNORE_NUMERIC_TYPES) {
// The code below was added for a long time ago. Perhaps it is still relevant for some databases.
// But there are databases like Netezza or Snowflake, which actually contain such data types as NUMBER and NUMERIC.
// Ignore abstract types. There can be multiple numeric types with the same name
// but different scale/precision properties
ignoredTypes.add("NUMBER");
ignoredTypes.add("NUMERIC");
}
}
@NotNull
......
......@@ -47,9 +47,10 @@ public class HANASQLDialect extends GenericSQLDialect implements TPRuleProvider
private static final String[][] HANA_BEGIN_END_BLOCK = new String[][]{
{SQLConstants.BLOCK_BEGIN, SQLConstants.BLOCK_END},
{"IF", SQLConstants.BLOCK_END},
{"IF", SQLConstants.BLOCK_END + " IF"},
{SQLConstants.KEYWORD_CASE, SQLConstants.BLOCK_END},
{"FOR", SQLConstants.BLOCK_END + " FOR"}
{"FOR", SQLConstants.BLOCK_END + " FOR"},
{"WHILE", SQLConstants.BLOCK_END + " WHILE"}
};
public HANASQLDialect() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册