HHH-15890 Fix shouldEmulateFetchClause method for DB2(i)SqlAstTranslator

This commit is contained in:
Marco Belladelli 2023-01-09 17:15:06 +01:00 committed by Christian Beikov
parent dcc05b8c6c
commit ab86055565
2 changed files with 24 additions and 12 deletions

View File

@ -34,12 +34,18 @@ public class DB2iLegacySqlAstTranslator<T extends JdbcOperation> extends DB2Lega
@Override
protected boolean shouldEmulateFetchClause(QueryPart queryPart) {
// Percent fetches or ties fetches aren't supported in DB2 iSeries
// According to LegacyDB2LimitHandler, variable limit also isn't supported before 7.1
return getQueryPartForRowNumbering() != queryPart && (
useOffsetFetchClause( queryPart ) && !isRowsOnlyFetchClauseType( queryPart )
|| version.isBefore(7, 10) && ( queryPart.isRoot() && hasLimit() || !( queryPart.getFetchClauseExpression() instanceof Literal ) )
);
// Check if current query part is already row numbering to avoid infinite recursion
if ( getQueryPartForRowNumbering() == queryPart ) {
return false;
}
// Percent fetches or ties fetches aren't supported in DB2
if ( useOffsetFetchClause( queryPart ) && !isRowsOnlyFetchClauseType( queryPart ) ) {
return true;
}
// According to LegacyDB2LimitHandler, variable limit also isn't supported before 7.10
return version.isBefore(7, 10)
&& queryPart.getFetchClauseExpression() != null
&& !( queryPart.getFetchClauseExpression() instanceof Literal );
}
@Override

View File

@ -32,12 +32,18 @@ public class DB2iSqlAstTranslator<T extends JdbcOperation> extends DB2SqlAstTran
@Override
protected boolean shouldEmulateFetchClause(QueryPart queryPart) {
// Percent fetches or ties fetches aren't supported in DB2 iSeries
// According to LegacyDB2LimitHandler, variable limit also isn't supported before 7.1
return getQueryPartForRowNumbering() != queryPart && (
useOffsetFetchClause( queryPart ) && !isRowsOnlyFetchClauseType( queryPart )
|| version.isBefore(7, 10) && ( queryPart.isRoot() && hasLimit() || !( queryPart.getFetchClauseExpression() instanceof Literal ) )
);
// Check if current query part is already row numbering to avoid infinite recursion
if ( getQueryPartForRowNumbering() == queryPart ) {
return false;
}
// Percent fetches or ties fetches aren't supported in DB2
if ( useOffsetFetchClause( queryPart ) && !isRowsOnlyFetchClauseType( queryPart ) ) {
return true;
}
// According to LegacyDB2LimitHandler, variable limit also isn't supported before 7.10
return version.isBefore(7, 10)
&& queryPart.getFetchClauseExpression() != null
&& !( queryPart.getFetchClauseExpression() instanceof Literal );
}
@Override