Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
9591d7d
#882 jdp-2025-06: Schema Support
mrotteveel Jun 18, 2025
9865b6b
#882 Fix tests failing due to Firebird 6 schemas
mrotteveel Jun 18, 2025
a3c5979
#882 Implement to DatabaseMetaData.getSchemas return schemas
mrotteveel Jun 19, 2025
7deb6ed
#882 Implement DatabaseMetaData informational methods to report schem…
mrotteveel Jun 19, 2025
740ce4d
Use isNullOrEmpty
mrotteveel Jun 19, 2025
286eea0
#882 Schema support for DatabaseMetaData.getProcedures
mrotteveel Jun 19, 2025
44cccc2
#882 Use SYSTEM unquoted due to dialect 1 support
mrotteveel Jun 19, 2025
d34af61
#882 Schema support for getBestRowIdentifier
mrotteveel Jun 21, 2025
05edd2d
#882 Schema support for getColumnPrivileges
mrotteveel Jun 21, 2025
7699234
#882 Schema support for getColumns
mrotteveel Jun 21, 2025
1d30a6d
#882 Schema support for getImportedKeys/getExportedKeys/getCrossRefer…
mrotteveel Jun 21, 2025
69effeb
#882 Schema support for getFunctionColumns
mrotteveel Jun 22, 2025
a5d8434
#882 Schema support for getFunctions
mrotteveel Jun 22, 2025
c08df8b
#882 Schema support for getIndexInfo
mrotteveel Jun 22, 2025
a1655eb
#882 Schema support for getPrimaryKeys
mrotteveel Jun 22, 2025
6b55727
#882 Schema support for getProcedureColumns
mrotteveel Jun 22, 2025
584e2cc
#882 Schema support for getPseudoColumns
mrotteveel Jun 22, 2025
6bdb4bc
#882 Schema support for getTablePrivileges
mrotteveel Jun 23, 2025
73ebef5
#882 Schema support for getTables
mrotteveel Jun 23, 2025
90ce855
#882 Schema support for getCatalogs
mrotteveel Jun 23, 2025
11349a7
Mark metadata classes sealed or final
mrotteveel Jun 23, 2025
ea0a273
#882 Schema support for getXXXSourceCode
mrotteveel Jun 23, 2025
b60c7d6
Add ifSchemaElse also to FirebirdSupportInfo
mrotteveel Jun 23, 2025
a154551
#882 Client props, xid detection
mrotteveel Jun 24, 2025
18a5228
#882 Retrieve schema name in column information
mrotteveel Jun 24, 2025
bed0828
#882 Incomplete change to selectable procedure detection
mrotteveel Jun 24, 2025
ce3abcc
#882 Misc wording of jdp-2025-06
mrotteveel Jun 24, 2025
d365d92
#882 Define connection property searchPath
mrotteveel Jun 24, 2025
276d8bc
Add supportInfoFor(FirebirdConnection) to avoid wrapper check
mrotteveel Jun 25, 2025
501eb78
Tighten up StoredProcedureMetaData, use support info
mrotteveel Jun 25, 2025
ca102d2
#882 Implement Connection.get/setSchema
mrotteveel Jul 9, 2025
6a7b308
#882 Additional schema tests for FBResultSetMetaData
mrotteveel Jul 12, 2025
aa3d585
#882 Modify FBRowUpdater to search for schema
mrotteveel Jul 13, 2025
1f839f0
Deduplicate strings in StatementInfoProcessor
mrotteveel Jul 13, 2025
fbff0a6
Add some todo for later
mrotteveel Jul 14, 2025
10ed654
#882 Improve schema test coverage
mrotteveel Jul 17, 2025
3662432
#882 Improve schema test coverage (getFunctions)
mrotteveel Jul 17, 2025
b83f275
Replace QualifiedName with ObjectReference
mrotteveel Jul 18, 2025
2cb017e
Add schema support assumption to test
mrotteveel Jul 18, 2025
b8769ad
#882 Improve schema test coverage (getProcedures/getProcedureColumns)
mrotteveel Jul 22, 2025
099a4b2
#882 Improve schema test coverage (getIndexInfo/getPrimaryKeys)
mrotteveel Jul 22, 2025
6a9febc
#882 Improve schema test coverage (getPseudoColumns/getTables)
mrotteveel Jul 22, 2025
48f4b7c
#882 Improve schema test coverage (getTablePrivileges)
mrotteveel Jul 22, 2025
24478cf
#882 schema support for generated keys
mrotteveel Jul 29, 2025
d251d84
#882 Add schema support for FBCallableStatement
mrotteveel Oct 9, 2025
82aa541
Fix test failure on Firebird 5 and older
mrotteveel Oct 9, 2025
a7542c0
#882 Document decision not to backport schema support to Jaybird 6
mrotteveel Oct 11, 2025
04523d7
Misc. copy editing and fixing typos
mrotteveel Oct 11, 2025
381b792
#882 Add JB_PROCEDURE_SOURCE column to getProcedures
mrotteveel Oct 13, 2025
102a856
#882 Reject idea to add column with schemas to getCatalogs
mrotteveel Oct 13, 2025
567cdea
Remove unnecessary caching from BasicVersion
mrotteveel Oct 17, 2025
e2e4e87
#882 Schema support for StatisticsManager.getTableStatistics
mrotteveel Oct 17, 2025
2353b24
#882 Schema support for FBTableStatisticsManager
mrotteveel Oct 18, 2025
c2320ed
Fixed wrong name
mrotteveel Oct 19, 2025
180999c
#882 Added setters to FirebirdConnection to set search path
mrotteveel Oct 19, 2025
d934271
Document compatibility issue with schema(Pattern) in dbmd
mrotteveel Oct 25, 2025
a35a3a0
Correct documentation of getXXXSourceCode methods
mrotteveel Oct 30, 2025
48514d5
Misc review changes
mrotteveel Oct 30, 2025
13e38c3
Use Collection instead of List, use common code path
mrotteveel Nov 3, 2025
4a83dec
Simplify version string creation in GDSServerVersion
mrotteveel Nov 3, 2025
ec1056e
SPECIFIC_NAME should not include the schema
mrotteveel Nov 3, 2025
0c9efec
Update error codes and messages from 6.0.0.1338
mrotteveel Nov 4, 2025
e37afa1
Ignore drop schema failure, refactor to single code path
mrotteveel Nov 4, 2025
588a017
Finalize jdp-2025-06
mrotteveel Nov 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#882 Implement to DatabaseMetaData.getSchemas return schemas
  • Loading branch information
mrotteveel committed Oct 25, 2025
commit a3c597965e2dfced7199a13a288d3d2be129e82c
15 changes: 15 additions & 0 deletions src/docs/asciidoc/release_notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,21 @@ Artificial testing on local WiFi with small blobs (200 bytes) shows a 30,000-45,

This optimization was backported to Jaybird 5.0.8 and Jaybird 6.0.2.

[#schemas]
=== Schema support

Firebird 6.0 introduces schemas, and Jaybird 7 provides support for schemas as defined in the JDBC specification.

Changes include:

* `DatabaseMetaData`
** `getSchemas()` returns all defined schemas
** `getSchemas(String catalog, String schemaPattern)` returns all schemas matching the `LIKE` pattern `schemaPattern`, with the following caveats
*** `catalog` non-empty will return no rows;
we recommend to always use `null` for `catalog`.
*** `schemaPattern` empty will return no rows (there are no schemas with an empty name);
use `null` or `"%"` to match all schemas

// TODO add major changes

[#other-fixes-and-changes]
Expand Down
10 changes: 5 additions & 5 deletions src/main/org/firebirdsql/jdbc/FBDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,11 @@ public ResultSet getSchemas() throws SQLException {
return getSchemas(null, null);
}

@Override
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
return GetSchemas.create(getDbMetadataMediator()).getSchemas(catalog, schemaPattern);
}

/**
* {@inheritDoc}
* <p>
Expand Down Expand Up @@ -1765,11 +1770,6 @@ public ResultSet getFunctions(String catalog, String schemaPattern, String funct
return GetFunctions.create(getDbMetadataMediator()).getFunctions(catalog, functionNamePattern);
}

@Override
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
return GetSchemas.create(getDbMetadataMediator()).getSchemas();
}

@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return iface != null && iface.isAssignableFrom(FBDatabaseMetaData.class);
Expand Down
92 changes: 85 additions & 7 deletions src/main/org/firebirdsql/jdbc/metadata/GetSchemas.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
package org.firebirdsql.jdbc.metadata;

import org.firebirdsql.gds.ng.fields.RowDescriptor;
import org.firebirdsql.gds.ng.fields.RowValue;
import org.firebirdsql.jdbc.DbMetadataMediator;
import org.firebirdsql.jdbc.FBResultSet;
import org.firebirdsql.jdbc.DbMetadataMediator.MetadataQuery;
import org.firebirdsql.util.FirebirdSupportInfo;

import java.sql.ResultSet;
import java.sql.SQLException;

import static java.util.Collections.emptyList;
import static org.firebirdsql.gds.ISCConstants.SQL_VARYING;
import static org.firebirdsql.jdbc.metadata.FbMetadataConstants.OBJECT_NAME_LENGTH;

Expand All @@ -20,23 +21,100 @@
* @author Mark Rotteveel
* @since 5
*/
public final class GetSchemas {
public abstract class GetSchemas extends AbstractMetadataMethod {

private static final RowDescriptor ROW_DESCRIPTOR = DbMetadataMediator.newRowDescriptorBuilder(2)
.at(0).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "TABLE_SCHEM", "TABLESCHEMAS").addField()
.at(1).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "TABLE_CATALOG", "TABLESCHEMAS").addField()
.toRowDescriptor();

private GetSchemas() {
private GetSchemas(DbMetadataMediator mediator) {
super(ROW_DESCRIPTOR, mediator);
}

public ResultSet getSchemas() throws SQLException {
return new FBResultSet(ROW_DESCRIPTOR, emptyList());
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
if (!(catalog == null || catalog.isEmpty()) || "".equals(schemaPattern)) {
// matching schema name not possible
return createEmpty();
}
MetadataQuery metadataQuery = createGetSchemasQuery(schemaPattern);
return createMetaDataResultSet(metadataQuery);
}

@Override
final RowValue createMetadataRow(ResultSet rs, RowValueBuilder valueBuilder) throws SQLException {
return valueBuilder
.at(0).setString(rs.getString("TABLE_SCHEM"))
.toRowValue(true);
}

abstract MetadataQuery createGetSchemasQuery(String schemaPattern);

@SuppressWarnings("unused")
public static GetSchemas create(DbMetadataMediator mediator) {
return new GetSchemas();
FirebirdSupportInfo firebirdSupportInfo = mediator.getFirebirdSupportInfo();
// NOTE: Indirection through static method prevents unnecessary classloading
if (firebirdSupportInfo.isVersionEqualOrAbove(6)) {
return FB6.createInstance(mediator);
} else {
return FB5.createInstance(mediator);
}
}

/**
* Implementation for Firebird 5.0 and older.
*/
private static final class FB5 extends GetSchemas {

private FB5(DbMetadataMediator mediator) {
super(mediator);
}

private static GetSchemas createInstance(DbMetadataMediator mediator) {
return new FB5(mediator);
}

@Override
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
return createEmpty();
}

@Override
MetadataQuery createGetSchemasQuery(String schemaPattern) {
throw new UnsupportedOperationException("This method should not get called for Firebird 5.0 and older");
}

}

/**
* Implementation for Firebird 6.0 and higher.
*/
private static final class FB6 extends GetSchemas {

private static final String GET_SCHEMAS_FRAGMENT_6 = """
select RDB$SCHEMA_NAME as TABLE_SCHEM
from "SYSTEM".RDB$SCHEMAS
""";

private static final String GET_SCHEMAS_ORDER_BY_6 = "\norder by RDB$SCHEMA_NAME";

private FB6(DbMetadataMediator mediator) {
super(mediator);
}

private static GetSchemas createInstance(DbMetadataMediator mediator) {
return new FB6(mediator);
}

@Override
MetadataQuery createGetSchemasQuery(String schemaPattern) {
var schemaClause = new Clause("RDB$SCHEMA_NAME", schemaPattern);
String sql = GET_SCHEMAS_FRAGMENT_6
+ (schemaClause.hasCondition() ? "\nwhere " + schemaClause.getCondition(false) : "")
+ GET_SCHEMAS_ORDER_BY_6;
return new MetadataQuery(sql, Clause.parameters(schemaClause));
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import org.junit.jupiter.api.extension.ExtensionContext;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static java.util.Collections.emptyList;
import static org.firebirdsql.common.FBTestProperties.createFBManager;
Expand All @@ -40,7 +41,7 @@ public abstract class UsesDatabaseExtension {
private final boolean initialCreate;
private FBManager fbManager = null;
private final List<String> initStatements;
private final List<String> databasesToDrop = new ArrayList<>();
private final Set<String> databasesToDrop = new HashSet<>();

private UsesDatabaseExtension(boolean initialCreate) {
this(initialCreate, emptyList());
Expand Down Expand Up @@ -72,6 +73,7 @@ void sharedAfter() {
} catch (Exception e){
System.getLogger(getClass().getName()).log(System.Logger.Level.ERROR, "Exception dropping DBs", e);
} finally {
databasesToDrop.clear();
try {
if (!(fbManager == null || fbManager.getState().equals("Stopped"))) {
fbManager.stop();
Expand Down
Loading