HHH-15009 Allow augmenting supported physical table types through dialect for H2 2.0.202+ support

This commit is contained in:
Christian Beikov 2022-01-06 18:32:27 +01:00
parent fe44411e60
commit 6feb33f4e1
3 changed files with 24 additions and 9 deletions

View File

@ -3487,6 +3487,10 @@ public abstract class Dialect implements ConversionContext {
return true;
}
public void augmentPhysicalTableTypes(List<String> tableTypesList) {
// nothing to do
}
public void augmentRecognizedTableTypes(List<String> tableTypesList) {
// nothing to do
}

View File

@ -207,7 +207,7 @@ public class H2Dialect extends Dialect {
public boolean hasOddDstBehavior() {
// H2 1.4.200 has a bug: https://github.com/h2database/h2database/issues/3184
return getVersion().isSame( 1, 4, 200 );
return getVersion().isSameOrAfter( 1, 4, 200 );
}
@Override
@ -271,6 +271,13 @@ public class H2Dialect extends Dialect {
CommonFunctionFactory.rownum( queryEngine );
}
@Override
public void augmentPhysicalTableTypes(List<String> tableTypesList) {
if ( getVersion().isSameOrAfter( 2 ) ) {
tableTypesList.add( "BASE TABLE" );
}
}
@Override
public int getMaxVarcharLength() {
return 1_048_576;

View File

@ -84,13 +84,19 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt
""
)
);
final List<String> physicalTableTypesList = new ArrayList<>();
if ( ! StringHelper.isBlank( extraPhysicalTableTypesConfig ) ) {
this.extraPhysicalTableTypes = StringHelper.splitTrimmingTokens(
",;",
extraPhysicalTableTypesConfig,
false
Collections.addAll(
physicalTableTypesList,
StringHelper.splitTrimmingTokens(
",;",
extraPhysicalTableTypesConfig,
false
)
);
}
extractionContext.getJdbcEnvironment().getDialect().augmentPhysicalTableTypes( physicalTableTypesList );
this.extraPhysicalTableTypes = physicalTableTypesList.toArray( new String[0] );
final List<String> tableTypesList = new ArrayList<>();
tableTypesList.add( "TABLE" );
@ -98,9 +104,7 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt
if ( ConfigurationHelper.getBoolean( AvailableSettings.ENABLE_SYNONYMS, configService.getSettings(), false ) ) {
tableTypesList.add( "SYNONYM" );
}
if ( extraPhysicalTableTypes != null ) {
Collections.addAll( tableTypesList, extraPhysicalTableTypes );
}
Collections.addAll( tableTypesList, extraPhysicalTableTypes );
extractionContext.getJdbcEnvironment().getDialect().augmentRecognizedTableTypes( tableTypesList );
this.tableTypes = tableTypesList.toArray( new String[0] );
@ -1125,7 +1129,7 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt
true, // DO require up-to-date results
resultSet -> {
while ( resultSet.next() ) {
if ( resultSet.getShort(getResultSetIndexTypeLabel() ) == DatabaseMetaData.tableIndexStatistic ) {
if ( resultSet.getShort( getResultSetIndexTypeLabel() ) == DatabaseMetaData.tableIndexStatistic ) {
continue;
}