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 Improve schema test coverage (getPseudoColumns/getTables)
  • Loading branch information
mrotteveel committed Oct 25, 2025
commit 6a9febc2ffe1096f933be1c245be6568dfec61d8
9 changes: 5 additions & 4 deletions src/test/org/firebirdsql/common/FBTestProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,16 @@ public static <T> T ifSchemaElse(T forSchema, T withoutSchema) {
}

/**
* Helper method that replaces {@code "PUBLIC"} with {@code ""} if schemas are not supported.
* Helper method that replaces {@code "PUBLIC"} or {@code "SYSTEM"} with {@code ""} if schemas are not supported.
*
* @param schemaName
* schema name
* @return {@code schemaName}, or &mdash; if {@code schemaName} is {@code "PUBLIC"} and schemas are not supported
* &mdash; {@code ""}
* @return {@code schemaName}, or &mdash; if {@code schemaName} is {@code "PUBLIC"} or {@code "SYSTEM"} and schemas
* are not supported &mdash; {@code ""}
*/
public static String resolveSchema(String schemaName) {
if (!getDefaultSupportInfo().supportsSchemas() && "PUBLIC".equals(schemaName)) {
if (!getDefaultSupportInfo().supportsSchemas()
&& ("PUBLIC".equals(schemaName) || "SYSTEM".equals(schemaName))) {
return "";
}
return schemaName;
Expand Down
122 changes: 80 additions & 42 deletions src/test/org/firebirdsql/jdbc/FBDatabaseMetaDataPseudoColumnsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,73 @@
package org.firebirdsql.jdbc;

import org.firebirdsql.common.extension.UsesDatabaseExtension;
import org.firebirdsql.util.FirebirdSupportInfo;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.sql.*;
import java.util.*;

import static org.firebirdsql.common.FBTestProperties.getConnectionViaDriverManager;
import static org.firebirdsql.common.FBTestProperties.getDefaultSupportInfo;
import static org.firebirdsql.common.FBTestProperties.ifSchemaElse;
import static org.firebirdsql.common.FBTestProperties.resolveSchema;
import static org.firebirdsql.common.FbAssumptions.assumeFeature;
import static org.firebirdsql.common.JdbcResourceHelper.closeQuietly;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

class FBDatabaseMetaDataPseudoColumnsTest {

// TODO Add schema support: tests involving other schema

//@formatter:off
private static final String NORMAL_TABLE_NAME = "NORMAL_TABLE";
private static final String CREATE_NORMAL_TABLE = "create table " + NORMAL_TABLE_NAME + " ( "
+ " ID integer primary key"
+ ")";
private static final String NORMAL_TABLE2_NAME = "NORMAL_TABLE2";
private static final String CREATE_NORMAL_TABLE2 = "create table " + NORMAL_TABLE2_NAME + " ( "
+ " ID integer primary key"
+ ")";
private static final String CREATE_NORMAL_TABLE = """
create table NORMAL_TABLE (
ID integer primary key
)""";
private static final String CREATE_NORMAL_TABLE2 = """
create table NORMAL_TABLE2 (
ID integer primary key
)""";
private static final String SINGLE_VIEW_NAME = "SINGLE_VIEW";
private static final String CREATE_SINGLE_VIEW =
"create view " + SINGLE_VIEW_NAME + " as select id from " + NORMAL_TABLE_NAME;
"create view SINGLE_VIEW as select id from NORMAL_TABLE";
private static final String MULTI_VIEW_NAME = "MULTI_VIEW";
private static final String CREATE_MULTI_VIEW = "create view " + MULTI_VIEW_NAME + " as "
+ "select a.id as id1, b.id as id2 "
+ "from " + NORMAL_TABLE_NAME + " as a, " + NORMAL_TABLE2_NAME + " as b";
private static final String CREATE_MULTI_VIEW =
"create view MULTI_VIEW as select a.id as id1, b.id as id2 from NORMAL_TABLE as a, NORMAL_TABLE2 as b";
private static final String EXTERNAL_TABLE_NAME = "EXTERNAL_TABLE";
private static final String CREATE_EXTERNAL_TABLE = "create table " + EXTERNAL_TABLE_NAME
+ " external file 'test_external_tbl.dat' ( "
+ " ID integer not null"
+ ")";
private static final String CREATE_EXTERNAL_TABLE = """
create table EXTERNAL_TABLE
external file 'test_external_tbl.dat' (
ID integer not null
)""";
private static final String GTT_PRESERVE_NAME = "GTT_PRESERVE";
private static final String CREATE_GTT_PRESERVE = "create global temporary table " + GTT_PRESERVE_NAME + " ("
+ " ID integer primary key"
+ ") "
+ " on commit preserve rows ";
private static final String CREATE_GTT_PRESERVE = """
create global temporary table GTT_PRESERVE (
ID integer primary key
) on commit preserve rows""";
private static final String GTT_DELETE_NAME = "GTT_DELETE";
private static final String CREATE_GTT_DELETE = "create global temporary table " + GTT_DELETE_NAME + " ("
+ " ID integer primary key"
+ ") "
+ " on commit delete rows ";
//@formatter:on
private static final String CREATE_GTT_DELETE = """
create global temporary table GTT_DELETE (
ID integer primary key
) on commit delete rows""";
private static final String CREATE_OTHER_SCHEMA = "create schema OTHER_SCHEMA";
private static final String NORMAL_TABLE3_NAME = "NORMAL_TABLE3";
private static final String CREATE_OTHER_SCHEMA_NORMAL_TABLE3 = """
create table OTHER_SCHEMA.NORMAL_TABLE3 (
ID integer primary key
)""";

private static final MetadataResultSetDefinition getPseudoColumnsDefinition =
new MetadataResultSetDefinition(PseudoColumnMetaData.class);

@RegisterExtension
static final UsesDatabaseExtension.UsesDatabaseForAll usesDatabase = UsesDatabaseExtension.usesDatabaseForAll(
CREATE_NORMAL_TABLE,
CREATE_NORMAL_TABLE2,
CREATE_SINGLE_VIEW,
CREATE_MULTI_VIEW,
CREATE_EXTERNAL_TABLE,
CREATE_GTT_PRESERVE,
CREATE_GTT_DELETE);
static final UsesDatabaseExtension.UsesDatabaseForAll usesDatabase =
UsesDatabaseExtension.usesDatabaseForAll(getDbInitStatements());

private static final boolean supportsRecordVersion = getDefaultSupportInfo()
.supportsRecordVersionPseudoColumn();
Expand All @@ -80,6 +83,24 @@ static void setupAll() throws SQLException {
dbmd = con.getMetaData();
}

private static List<String> getDbInitStatements() {
var statements = new ArrayList<>(List.of(
CREATE_NORMAL_TABLE,
CREATE_NORMAL_TABLE2,
CREATE_SINGLE_VIEW,
CREATE_MULTI_VIEW,
CREATE_EXTERNAL_TABLE,
CREATE_GTT_PRESERVE,
CREATE_GTT_DELETE));
if (getDefaultSupportInfo().supportsSchemas()) {
statements.addAll(List.of(
CREATE_OTHER_SCHEMA,
CREATE_OTHER_SCHEMA_NORMAL_TABLE3));
}

return statements;
}

@AfterAll
static void tearDownAll() throws SQLException {
try {
Expand All @@ -100,12 +121,14 @@ void testPseudoColumnsMetaDataColumns() throws Exception {
}
}

@Test
void testNormalTable_allPseudoColumns() throws Exception {
@ParameterizedTest
@NullSource
@ValueSource(strings = { "%", "PUBLIC" })
void testNormalTable_allPseudoColumns(String schemaPattern) throws Exception {
List<Map<PseudoColumnMetaData, Object>> validationRules =
createStandardValidationRules(NORMAL_TABLE_NAME, "NO");

ResultSet pseudoColumns = dbmd.getPseudoColumns(null, null, NORMAL_TABLE_NAME, "%");
ResultSet pseudoColumns = dbmd.getPseudoColumns(null, resolveSchema(schemaPattern), NORMAL_TABLE_NAME, "%");
validate(pseudoColumns, validationRules);
}

Expand Down Expand Up @@ -253,8 +276,9 @@ void testPattern_wildCardTable() throws Exception {
tableCount += 1;
}

// System tables + the 7 tables created for this test
assertEquals(getDefaultSupportInfo().getSystemTableCount() + 7, tableCount,
// System tables + the tables created for this test
int testTableCount = getDefaultSupportInfo().supportsSchemas() ? 8 : 7;
assertEquals(getDefaultSupportInfo().getSystemTableCount() + testTableCount, tableCount,
"Unexpected number of pseudo columns");
}
}
Expand All @@ -267,12 +291,25 @@ void testPattern_nullTable() throws Exception {
tableCount += 1;
}

// System tables + the 7 tables created for this test
assertEquals(getDefaultSupportInfo().getSystemTableCount() + 7, tableCount,
// System tables + the tables created for this test
int testTableCount = getDefaultSupportInfo().supportsSchemas() ? 8 : 7;
assertEquals(getDefaultSupportInfo().getSystemTableCount() + testTableCount, tableCount,
"Unexpected number of pseudo columns");
}
}

@ParameterizedTest
@NullSource
@ValueSource(strings = { "%", "OTHER_SCHEMA", "OTHER\\_SCHEMA", "OTHER%" })
void testOtherSchemaNormalTable2_allPseudoColumns(String schemaPattern) throws Exception {
assumeFeature(FirebirdSupportInfo::supportsSchemas, "Test requires schema support");
List<Map<PseudoColumnMetaData, Object>> validationRules =
createStandardValidationRules("OTHER_SCHEMA", NORMAL_TABLE3_NAME, "NO");

ResultSet pseudoColumns = dbmd.getPseudoColumns(null, schemaPattern, NORMAL_TABLE3_NAME, "%");
validate(pseudoColumns, validationRules);
}

private List<Map<PseudoColumnMetaData, Object>> createStandardValidationRules(String tableName,
String recordVersionNullable) {
return createStandardValidationRules(ifSchemaElse("PUBLIC", null), tableName, recordVersionNullable);
Expand Down Expand Up @@ -342,6 +379,7 @@ private Map<PseudoColumnMetaData, Object> createDbkeyValidationRules(String sche
return rules;
}

@SuppressWarnings("SameParameterValue")
private Map<PseudoColumnMetaData, Object> createRecordVersionValidationRules(String tableName, String nullable) {
return createRecordVersionValidationRules(ifSchemaElse("PUBLIC", null), tableName, nullable);
}
Expand Down
Loading