Skip to content

Commit

Permalink
#791 Use column name JB_PK_INDEX_NAME, for consistency with upcoming …
Browse files Browse the repository at this point in the history
…changes
  • Loading branch information
mrotteveel committed Apr 1, 2024
1 parent 074d2a2 commit c763722
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/docs/asciidoc/release_notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ We do not plan to remove this API at this time, but we recommend that you switch
* Fixed: Use of offset timezone names (e.g. `+05:00`) for `sessionTimeZone` would result in a warning being logged, and an incorrect conversion applied (in UTC instead of the offset) when using the legacy time types (https://github.com/FirebirdSQL/jaybird/issues/786[#786])
+
This change was also backported to Jaybird 5.0.4.
* New feature: Added column `JB_INDEX_NAME` to the result set of `DatabaseMetaData.getPrimaryKeys` with the name of the index backing the primary key (https://github.com/FirebirdSQL/jaybird/issues/791[#791])
* New feature: Added column `JB_PK_INDEX_NAME` to the result set of `DatabaseMetaData.getPrimaryKeys` with the name of the index backing the primary key (https://github.com/FirebirdSQL/jaybird/issues/791[#791])
+
Given this is a non-standard extension, it is advisable to retrieve this column by name, not by position.
* Improvement: `sessionTimeZone` now also accepts the Java offset names (`GMT[{plus}-]HH:MM`), which will be automatically converted to the Firebird compatible name (`[{plus}-]HH:MM`).
Expand Down
2 changes: 1 addition & 1 deletion src/main/org/firebirdsql/jdbc/FBDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ public ResultSet getVersionColumns(String catalog, String schema, String table)
* <p>
* Jaybird defines these additional columns:
* <ol start="7">
* <li><b>JB_INDEX_NAME</b> String =&gt; Index backing the primary key</li>
* <li><b>JB_PK_INDEX_NAME</b> String =&gt; Index backing the primary key</li>
* </ol>
* </p>
*/
Expand Down
6 changes: 3 additions & 3 deletions src/main/org/firebirdsql/jdbc/metadata/GetPrimaryKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public final class GetPrimaryKeys extends AbstractMetadataMethod {
.at(3).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "COLUMN_NAME", COLUMNINFO).addField()
.at(4).simple(SQL_SHORT, 0, "KEY_SEQ", COLUMNINFO).addField()
.at(5).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "PK_NAME", COLUMNINFO).addField()
.at(6).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "JB_INDEX_NAME", COLUMNINFO).addField()
.at(6).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "JB_PK_INDEX_NAME", COLUMNINFO).addField()
.toRowDescriptor();

private static final String GET_PRIMARY_KEYS_START = """
Expand All @@ -57,7 +57,7 @@ public final class GetPrimaryKeys extends AbstractMetadataMethod {
ISGMT.RDB$FIELD_NAME as COLUMN_NAME,
ISGMT.RDB$FIELD_POSITION + 1 as KEY_SEQ,
RC.RDB$CONSTRAINT_NAME as PK_NAME,
RC.RDB$INDEX_NAME as JB_INDEX_NAME
RC.RDB$INDEX_NAME as JB_PK_INDEX_NAME
from RDB$RELATION_CONSTRAINTS RC
inner join RDB$INDEX_SEGMENTS ISGMT
on RC.RDB$INDEX_NAME = ISGMT.RDB$INDEX_NAME
Expand Down Expand Up @@ -91,7 +91,7 @@ RowValue createMetadataRow(ResultSet rs, RowValueBuilder valueBuilder) throws SQ
.at(3).setString(rs.getString("COLUMN_NAME"))
.at(4).setShort(rs.getShort("KEY_SEQ"))
.at(5).setString(rs.getString("PK_NAME"))
.at(6).setString(rs.getString("JB_INDEX_NAME"))
.at(6).setString(rs.getString("JB_PK_INDEX_NAME"))
.toRowValue(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static Map<PrimaryKeysMetaData, Object> createPrimaryKeysRow(String tabl
rules.put(PrimaryKeysMetaData.KEY_SEQ, (short) keySeq);
rules.put(PrimaryKeysMetaData.PK_NAME,
UNNAMED_PK_PREFIX.equals(pkName) ? Matchers.startsWith(UNNAMED_PK_PREFIX) : pkName);
rules.put(PrimaryKeysMetaData.JB_INDEX_NAME,
rules.put(PrimaryKeysMetaData.JB_PK_INDEX_NAME,
UNNAMED_INDEX_PREFIX.equals(jbIndexName) ? Matchers.startsWith(UNNAMED_INDEX_PREFIX) : jbIndexName);
return rules;
}
Expand All @@ -186,7 +186,7 @@ private enum PrimaryKeysMetaData implements MetaDataInfo {
COLUMN_NAME(4, String.class),
KEY_SEQ(5, Short.class),
PK_NAME(6, String.class),
JB_INDEX_NAME(7, String.class);
JB_PK_INDEX_NAME(7, String.class);

private final int position;
private final Class<?> columnClass;
Expand Down

0 comments on commit c763722

Please sign in to comment.