@Override protected PostgreSchema fetchObject( @NotNull JDBCSession session, @NotNull PostgreDatabase owner, @NotNull JDBCResultSet resultSet) throws SQLException, DBException { String name = JDBCUtils.safeGetString(resultSet, "nspname"); if (name == null) { return null; } if (PostgreSchema.isUtilitySchema(name) && !owner.getDataSource().getContainer().isShowUtilityObjects()) { return null; } return new PostgreSchema(owner, name, resultSet); }
@NotNull @Override public JDBCStatement prepareLookupStatement( @NotNull JDBCSession session, @NotNull PostgreDatabase database, @Nullable PostgreSchema object, @Nullable String objectName) throws SQLException { /* // Do not apply filters // We need all schemas to have access to types return session.prepareStatement( "SELECT n.oid,n.* FROM pg_catalog.pg_namespace n ORDER BY nspname"); */ StringBuilder catalogQuery = new StringBuilder("SELECT n.oid,n.* FROM pg_catalog.pg_namespace n"); DBSObjectFilter catalogFilters = database.getDataSource().getContainer().getObjectFilter(PostgreSchema.class, null, false); if ((catalogFilters != null && !catalogFilters.isNotApplicable()) || object != null || objectName != null) { if (object != null || objectName != null) { catalogFilters = new DBSObjectFilter(); catalogFilters.addInclude(object != null ? object.getName() : objectName); } else { catalogFilters = new DBSObjectFilter(catalogFilters); // Always read catalog schema catalogFilters.addInclude(PostgreConstants.CATALOG_SCHEMA_NAME); } JDBCUtils.appendFilterClause(catalogQuery, catalogFilters, "nspname", true); } catalogQuery.append(" ORDER BY nspname"); JDBCPreparedStatement dbStat = session.prepareStatement(catalogQuery.toString()); if (catalogFilters != null) { JDBCUtils.setFilterParameters(dbStat, 1, catalogFilters); } return dbStat; }