Skip to content

Commit

Permalink
HHH-15177 - Remove support for PostgreSQL versions older than 11
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
  • Loading branch information
jrenaat authored and beikov committed Aug 28, 2023
1 parent f49535d commit 2136600
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 51 deletions.
8 changes: 0 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,6 @@ stage('Build') {
sh "./docker_db.sh postgresql"
state[buildEnv.tag]['containerName'] = "postgres"
break;
case "postgresql_10":
// use the postgis image to enable the PGSQL GIS (spatial) extension
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
docker.image('postgis/postgis:10-2.5').pull()
}
sh "./docker_db.sh postgresql_10"
state[buildEnv.tag]['containerName'] = "postgres"
break;
case "edb":
docker.image('quay.io/enterprisedb/edb-postgres-advanced:15.2-3.3-postgis').pull()
sh "./docker_db.sh edb"
Expand Down
9 changes: 2 additions & 7 deletions docker_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,9 @@ postgresql() {
postgresql_15
}

postgresql_9_5() {
postgresql_11() {
$CONTAINER_CLI rm -f postgres || true
$CONTAINER_CLI run --name postgres -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p5432:5432 -d docker.io/postgis/postgis:9.5-2.5
}

postgresql_10() {
$CONTAINER_CLI rm -f postgres || true
$CONTAINER_CLI run --name postgres -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p5432:5432 -d docker.io/postgis/postgis:10-2.5
$CONTAINER_CLI run --name postgres -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p5432:5432 -d docker.io/postgis/postgis:11-3.3
}

postgresql_13() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public Class<? extends Dialect> resolve(String name) {
return PostgreSQL94Dialect.class;
case "PostgreSQL95":
return PostgreSQL95Dialect.class;
case "PostgreSQL10":
return PostgreSQL10Dialect.class;
case "RDMSOS2200":
return RDMSOS2200Dialect.class;
case "SAPDB":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;

import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.PostgreSQLDialect;

/**
* An SQL dialect for Postgres 10 and later.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void verifyAllDialectNamingResolve() {
testDialectNamingResolution( PostgreSQL93Dialect.class );
testDialectNamingResolution( PostgreSQL94Dialect.class );
testDialectNamingResolution( PostgreSQL95Dialect.class );
testDialectNamingResolution( PostgreSQL10Dialect.class );

testDialectNamingResolution( SAPDBDialect.class );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle12cDialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.PostgreSQL10Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.PostgresPlusDialect;
import org.hibernate.dialect.SQLServer2008Dialect;
Expand Down Expand Up @@ -120,9 +119,8 @@ public Class<? extends Dialect> resolve(final String name) {
case "PostgreSQL93":
case "PostgreSQL94":
case "PostgreSQL95":
return findCommunityDialect( name );
case "PostgreSQL10":
return PostgreSQL10Dialect.class;
return findCommunityDialect( name );
case "Spanner":
return SpannerDialect.class;
case "SQLServer":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithMillis;

/**
* A {@linkplain Dialect SQL dialect} for PostgreSQL 10 and above.
* A {@linkplain Dialect SQL dialect} for PostgreSQL 11 and above.
*
* @author Gavin King
*/
public class PostgreSQLDialect extends Dialect {
protected final static DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 10 );
protected final static DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 11 );

private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate(this);

Expand Down Expand Up @@ -1034,9 +1034,7 @@ public SelectItemReferenceStrategy getGroupBySelectItemReferenceStrategy() {

@Override
public CallableStatementSupport getCallableStatementSupport() {
return getVersion().isSameOrAfter( 11 )
? PostgreSQLCallableStatementSupport.INSTANCE
: PostgreSQLCallableStatementSupport.V10_INSTANCE;
return PostgreSQLCallableStatementSupport.INSTANCE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ protected boolean supportsArrayConstructor() {

@Override
public boolean supportsFilterClause() {
return getDialect().getVersion().isSameOrAfter( 9, 4 );
return true;
}

@Override
protected String getForUpdate() {
return getDialect().getVersion().isSameOrAfter( 9, 3 ) ? " for no key update" : " for update";
return " for no key update";
}

@Override
Expand Down Expand Up @@ -228,29 +228,14 @@ protected void renderPartitionItem(Expression expression) {
// We render an empty group instead of literals as some DBs don't support grouping by literals
// Note that integer literals, which refer to select item positions, are handled in #visitGroupByClause
if ( expression instanceof Literal ) {
if ( getDialect().getVersion().isSameOrAfter( 9, 5 ) ) {
appendSql( "()" );
}
else {
appendSql( "(select 1" );
appendSql( getFromDualForSelectOnly() );
appendSql( ')' );
}
appendSql( "()" );
}
else if ( expression instanceof Summarization ) {
Summarization summarization = (Summarization) expression;
if ( getDialect().getVersion().isSameOrAfter( 9, 5 ) ) {
appendSql( summarization.getKind().sqlText() );
appendSql( OPEN_PARENTHESIS );
renderCommaSeparated( summarization.getGroupings() );
appendSql( CLOSE_PARENTHESIS );
}
else {
// This could theoretically be emulated by rendering all grouping variations of the query and
// connect them via union all but that's probably pretty inefficient and would have to happen
// on the query spec level
throw new UnsupportedOperationException( "Summarization is not supported by DBMS" );
}
appendSql( summarization.getKind().sqlText() );
appendSql( OPEN_PARENTHESIS );
renderCommaSeparated( summarization.getGroupings() );
appendSql( CLOSE_PARENTHESIS );
}
else {
expression.accept( this );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void verifyAllDialectNamingResolve() {

testDialectNamingResolution( PostgreSQLDialect.class );
testDialectNamingResolution( PostgresPlusDialect.class );
testDialectNamingResolution( PostgreSQL10Dialect.class );

testDialectNamingResolution( SQLServerDialect.class );
testDialectNamingResolution( SQLServer2008Dialect.class );
Expand Down
8 changes: 4 additions & 4 deletions nightly.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ stage('Configure') {
new BuildEnvironment( dbName: 'derby_10_14' ),
new BuildEnvironment( dbName: 'mysql_5_7' ),
new BuildEnvironment( dbName: 'mariadb_10_3' ),
new BuildEnvironment( dbName: 'postgresql_10' ),
new BuildEnvironment( dbName: 'postgresql_11' ),
new BuildEnvironment( dbName: 'edb_10' ),
new BuildEnvironment( dbName: 'oracle_11_2' ),
new BuildEnvironment( dbName: 'db2_10_5', longRunning: true ),
Expand Down Expand Up @@ -158,12 +158,12 @@ stage('Build') {
sh "./docker_db.sh postgresql"
state[buildEnv.tag]['containerName'] = "postgres"
break;
case "postgresql_10":
case "postgresql_11":
// use the postgis image to enable the PGSQL GIS (spatial) extension
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
docker.image('postgis/postgis:10-2.5').pull()
docker.image('postgis/postgis:11-3.3').pull()
}
sh "./docker_db.sh postgresql_10"
sh "./docker_db.sh postgresql_11"
state[buildEnv.tag]['containerName'] = "postgres"
break;
case "edb":
Expand Down

0 comments on commit 2136600

Please sign in to comment.