Skip to content

Commit

Permalink
JDBC-323 Fix searchability of blob types to be fully searchable on 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotteveel committed Jul 15, 2016
1 parent cdfb177 commit 2e571b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/org/firebirdsql/jdbc/FBDatabaseMetaData.java
Expand Up @@ -3853,8 +3853,12 @@ public ResultSet getTypeInfo() throws SQLException {
.at(17).simple(SQL_LONG, 0, "NUM_PREC_RADIX", "TYPEINFO").addField()
.toRowDescriptor();

final byte[] blobTypePred = firebirdSupportInfo.supportsFullSearchableBlobs()
? TYPE_SEARCHABLE
: TYPE_PRED_BASIC;

//dialect 3 only
final List<RowValue> rows = new ArrayList<>(17);
final List<RowValue> rows = new ArrayList<>(19);

//BIGINT=-5
rows.add(RowValue.of(rowDescriptor,
Expand All @@ -3864,8 +3868,8 @@ public ResultSet getTypeInfo() throws SQLException {

//LONGVARBINARY=-4
rows.add(RowValue.of(rowDescriptor,
getBytes("BLOB SUB_TYPE 0"), createShort(Types.LONGVARBINARY), INT_ZERO, null, null,
null, TYPE_NULLABLE, CASESENSITIVE, TYPE_PRED_NONE, UNSIGNED, FIXEDSCALE, NOTAUTOINC, null,
getBytes("BLOB SUB_TYPE BINARY"), createShort(Types.LONGVARBINARY), INT_ZERO, null, null,
null, TYPE_NULLABLE, CASESENSITIVE, blobTypePred, UNSIGNED, FIXEDSCALE, NOTAUTOINC, null,
SHORT_ZERO, SHORT_ZERO, createInt(SQL_BLOB), null, RADIX_TEN));

//VARBINARY=-3
Expand All @@ -3882,8 +3886,8 @@ public ResultSet getTypeInfo() throws SQLException {

//LONGVARCHAR=-1
rows.add(RowValue.of(rowDescriptor,
getBytes("BLOB SUB_TYPE 1"), createShort(Types.LONGVARCHAR), INT_ZERO, null, null,
null, TYPE_NULLABLE, CASESENSITIVE, TYPE_PRED_NONE, UNSIGNED, FIXEDSCALE, NOTAUTOINC, null,
getBytes("BLOB SUB_TYPE TEXT"), createShort(Types.LONGVARCHAR), INT_ZERO, null, null,
null, TYPE_NULLABLE, CASESENSITIVE, blobTypePred, UNSIGNED, FIXEDSCALE, NOTAUTOINC, null,
SHORT_ZERO, SHORT_ZERO, createInt(SQL_BLOB), null, RADIX_TEN));

//CHAR=1
Expand Down Expand Up @@ -3969,6 +3973,8 @@ FIXEDSCALE, NOTAUTOINC, null, SHORT_ZERO, SHORT_ZERO, createInt(SQL_VARYING), nu
createInt(SQL_ARRAY), null, RADIX_TEN));

//BLOB=2004
// Should we split this into all negative blob types currently known in the DB?
// Blob is potentially searchable with like, etc, acting as if it isn't.
rows.add(RowValue.of(rowDescriptor,
getBytes("BLOB SUB_TYPE <0 "), createShort(Types.BLOB), INT_ZERO, null, null, null,
TYPE_NULLABLE, CASESENSITIVE, TYPE_PRED_NONE, UNSIGNED, FIXEDSCALE, NOTAUTOINC, null, SHORT_ZERO,
Expand Down
7 changes: 7 additions & 0 deletions src/main/org/firebirdsql/util/FirebirdSupportInfo.java
Expand Up @@ -249,6 +249,13 @@ public boolean supportsGlobalTemporaryTables() {
return serverVersion.isEqualOrAbove(2, 5);
}

/**
* @return {@code true} when blobs are fully searchable (eg using `LIKE`).
*/
public boolean supportsFullSearchableBlobs() {
return serverVersion.isEqualOrAbove(2, 1);
}

/**
* @param serverVersion
* Server version
Expand Down

0 comments on commit 2e571b3

Please sign in to comment.