HHH-17094 - Remove support for MySQL versions older than 8.0

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2023-10-11 22:10:56 +02:00 committed by Christian Beikov
parent 0ded30a157
commit f12ef0fa79
12 changed files with 52 additions and 94 deletions

View File

@ -19,30 +19,6 @@ mysql() {
mysql_8_1
}
mysql_5_7() {
$CONTAINER_CLI rm -f mysql || true
$CONTAINER_CLI run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d docker.io/mysql:5.7.43 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --skip-character-set-client-handshake --log-bin-trust-function-creators=1
# Give the container some time to start
OUTPUT=
n=0
until [ "$n" -ge 5 ]
do
# Need to access STDERR. Thanks for the snippet https://stackoverflow.com/a/56577569/412446
{ OUTPUT="$( { $CONTAINER_CLI logs mysql; } 2>&1 1>&3 3>&- )"; } 3>&1;
if [[ $OUTPUT == *"ready for connections"* ]]; then
break;
fi
n=$((n+1))
echo "Waiting for MySQL to start..."
sleep 3
done
if [ "$n" -ge 5 ]; then
echo "MySQL failed to start and configure after 15 seconds"
else
echo "MySQL successfully started"
fi
}
mysql_8_0() {
$CONTAINER_CLI rm -f mysql || true
$CONTAINER_CLI run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d docker.io/mysql:8.0.31 --character-set-server=utf8mb4 --collation-server=utf8mb4_0900_as_cs --skip-character-set-client-handshake --log-bin-trust-function-creators=1
@ -984,7 +960,6 @@ if [ -z ${1} ]; then
echo -e "\tmysql"
echo -e "\tmysql_8_1"
echo -e "\tmysql_8_0"
echo -e "\tmysql_5_7"
echo -e "\toracle"
echo -e "\toracle_23"
echo -e "\toracle_21"

View File

@ -62,6 +62,8 @@ public class CommunityDialectSelector implements DialectSelector {
return MySQL5Dialect.class;
case "MySQL55":
return MySQL55Dialect.class;
case "MySQL57":
return MySQL57Dialect.class;
case "Oracle8i":
return Oracle8iDialect.class;
case "Oracle9i":

View File

@ -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.MySQLDialect;
/**
* @author Gail Badner

View File

@ -41,6 +41,7 @@ public class CommunityDialectSelectorTest {
testDialectNamingResolution( MySQL5Dialect.class );
testDialectNamingResolution( MySQL55Dialect.class );
testDialectNamingResolution( MySQL57Dialect.class );
testDialectNamingResolution( Oracle8iDialect.class );
testDialectNamingResolution( Oracle9iDialect.class );

View File

@ -25,7 +25,6 @@ import org.hibernate.dialect.HANARowStoreDialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MariaDB103Dialect;
import org.hibernate.dialect.MariaDBDialect;
import org.hibernate.dialect.MySQL57Dialect;
import org.hibernate.dialect.MySQL8Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle12cDialect;
@ -94,9 +93,8 @@ public class DefaultDialectSelector implements DialectSelector {
return MySQLDialect.class;
case "MySQL5":
case "MySQL55":
return findCommunityDialect( name );
case "MySQL57":
return MySQL57Dialect.class;
return findCommunityDialect( name );
case "MySQL8":
return MySQL8Dialect.class;
case "Oracle":

View File

@ -120,7 +120,7 @@ import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithM
*/
public class MySQLDialect extends Dialect {
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 5, 7 );
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 8 );
private final MySQLStorageEngine storageEngine = createStorageEngine();
private final SizeStrategy sizeStrategy = new SizeStrategyImpl() {
@ -622,22 +622,11 @@ public class MySQLDialect extends Dialect {
.register();
// pi() produces a value with 7 digits unless we're explicit
if ( getMySQLVersion().isSameOrAfter( 8 ) ) {
functionRegistry.patternDescriptorBuilder( "pi", "cast(pi() as double)" )
.setInvariantType( basicTypeRegistry.resolve( StandardBasicTypes.DOUBLE ) )
.setExactArgumentCount( 0 )
.setArgumentListSignature( "" )
.register();
}
else {
// But before MySQL 8, it's not possible to cast to double. Double has a default precision of 53
// and since the internal representation of pi has only 15 decimal places, we cast to decimal(53,15)
functionRegistry.patternDescriptorBuilder( "pi", "cast(pi() as decimal(53,15))" )
.setInvariantType( basicTypeRegistry.resolve( StandardBasicTypes.DOUBLE ) )
.setExactArgumentCount( 0 )
.setArgumentListSignature( "" )
.register();
}
functionRegistry.patternDescriptorBuilder( "pi", "cast(pi() as double)" )
.setInvariantType( basicTypeRegistry.resolve( StandardBasicTypes.DOUBLE ) )
.setExactArgumentCount( 0 )
.setArgumentListSignature( "" )
.register();
// By default char() produces a binary string, not a character string.
// (Note also that char() is actually a variadic function in MySQL.)
@ -1467,12 +1456,12 @@ public class MySQLDialect extends Dialect {
@Override
public boolean supportsSkipLocked() {
return getMySQLVersion().isSameOrAfter( 8 );
return true;
}
@Override
public boolean supportsNoWait() {
return getMySQLVersion().isSameOrAfter( 8 );
return true;
}
@Override
@ -1493,11 +1482,11 @@ public class MySQLDialect extends Dialect {
}
boolean supportsForShare() {
return getMySQLVersion().isSameOrAfter( 8 );
return true;
}
boolean supportsAliasLocks() {
return getMySQLVersion().isSameOrAfter( 8 );
return true;
}
@Override

View File

@ -122,7 +122,7 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
@Override
protected String getForShare(int timeoutMillis) {
return getDialect().getVersion().isSameOrAfter( 8 ) ? " for share" : " lock in share mode";
return " for share";
}
protected boolean shouldEmulateFetchClause(QueryPart queryPart) {
@ -156,16 +156,6 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
emulateValuesTableReferenceColumnAliasing( tableReference );
}
@Override
public void visitQueryPartTableReference(QueryPartTableReference tableReference) {
if ( getDialect().getVersion().isSameOrAfter( 8 ) ) {
super.visitQueryPartTableReference( tableReference );
}
else {
emulateQueryPartTableReferenceColumnAliasing( tableReference );
}
}
@Override
public void visitOffsetFetchClause(QueryPart queryPart) {
if ( !isRowNumberingCurrentQueryPart() ) {
@ -271,7 +261,7 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
@Override
protected boolean supportsSimpleQueryGrouping() {
return getDialect().getVersion().isSameOrAfter( 8 );
return true;
}
@Override
@ -281,7 +271,7 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
@Override
protected boolean supportsWithClause() {
return getDialect().getVersion().isSameOrAfter( 8 );
return true;
}
@Override
@ -289,11 +279,6 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
return " from dual";
}
@Override
protected String getFromDualForSelectOnly() {
return getDialect().getVersion().isSameOrAfter( 8 ) ? "" : getFromDual();
}
@Override
public MySQLDialect getDialect() {
return (MySQLDialect) DialectDelegateWrapper.extractRealDialect( super.getDialect() );

View File

@ -28,16 +28,18 @@ public class TiDBDialect extends MySQLDialect {
private static final DatabaseVersion VERSION57 = DatabaseVersion.make( 5, 7 );
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 5, 4 );
public TiDBDialect() {
this( DatabaseVersion.make(5, 4) );
this( MINIMUM_VERSION );
}
public TiDBDialect(DatabaseVersion version) {
super(version);
super( version );
}
public TiDBDialect(DialectResolutionInfo info) {
super(createVersion( info ), MySQLServerConfiguration.fromDatabaseMetadata( info.getDatabaseMetadata() ));
super( createVersion( info ), MySQLServerConfiguration.fromDatabaseMetadata( info.getDatabaseMetadata() ) );
registerKeywords( info );
}
@ -47,6 +49,11 @@ public class TiDBDialect extends MySQLDialect {
return VERSION57;
}
@Override
protected DatabaseVersion getMinimumSupportedVersion() {
return MINIMUM_VERSION;
}
@Override
protected void registerDefaultKeywords() {
super.registerDefaultKeywords();
@ -102,6 +109,11 @@ public class TiDBDialect extends MySQLDialect {
return true;
}
@Override
public boolean supportsSkipLocked() {
return false;
}
@Override
public boolean supportsNoWait() {
return true;
@ -112,6 +124,16 @@ public class TiDBDialect extends MySQLDialect {
return true;
}
@Override
boolean supportsForShare() {
return false;
}
@Override
boolean supportsAliasLocks() {
return false;
}
@Override
public String getReadLockString(int timeout) {
if ( timeout == LockOptions.NO_WAIT ) {

View File

@ -10,6 +10,7 @@ import org.hibernate.boot.registry.selector.internal.DefaultDialectSelector;
import org.hibernate.community.dialect.DerbyTenFiveDialect;
import org.hibernate.community.dialect.DerbyTenSevenDialect;
import org.hibernate.community.dialect.DerbyTenSixDialect;
import org.hibernate.community.dialect.MySQL57Dialect;
import org.hibernate.community.dialect.MySQL5Dialect;
import org.hibernate.dialect.*;

View File

@ -21,7 +21,6 @@ import org.hibernate.spatial.testing.dialects.db2.DB2TestSupport;
import org.hibernate.spatial.testing.dialects.h2gis.H2GisTestSupport;
import org.hibernate.spatial.testing.dialects.hana.HANATestSupport;
import org.hibernate.spatial.testing.dialects.mariadb.MariaDBTestSupport;
import org.hibernate.spatial.testing.dialects.mysql.MySQL56TestSupport;
import org.hibernate.spatial.testing.dialects.mysql.MySQL8TestSupport;
import org.hibernate.spatial.testing.dialects.oracle.OracleSDOTestSupport;
import org.hibernate.spatial.testing.dialects.postgis.PostgisTestSupport;
@ -61,7 +60,7 @@ public class TestSupportFactories {
if ( MySQLDialect.class.isAssignableFrom( dialect.getClass() ) ) {
return dialect.getVersion().isSameOrAfter( 8 ) ? MySQL8TestSupport.class : MySQL56TestSupport.class;
return MySQL8TestSupport.class;
}
if ( H2Dialect.class.isAssignableFrom( dialect.getClass() ) ) {

View File

@ -1,17 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.spatial.testing.dialects.mysql;
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
/**
* @author Karel Maesen, Geovise BVBA
* creation-date: 10/9/13
*/
public class MySQL56TestSupport extends MySQLTestSupport {
}

View File

@ -28,7 +28,7 @@ stage('Configure') {
this.environments = [
// Minimum supported versions
new BuildEnvironment( dbName: 'hsqldb_2_6' ),
new BuildEnvironment( dbName: 'mysql_5_7' ),
new BuildEnvironment( dbName: 'mysql_8_0' ),
new BuildEnvironment( dbName: 'mariadb_10_3' ),
new BuildEnvironment( dbName: 'postgresql_12' ),
new BuildEnvironment( dbName: 'edb_12' ),
@ -110,11 +110,11 @@ stage('Build') {
state[buildEnv.tag]['additionalOptions'] = state[buildEnv.tag]['additionalOptions'] +
" -Pgradle.libs.versions.hsqldb=2.6.1"
break;
case "mysql_5_7":
case "mysql_8_0":
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
docker.image('mysql:5.7.43').pull()
docker.image('mysql:8.0.31').pull()
}
sh "./docker_db.sh mysql_5_7"
sh "./docker_db.sh mysql_8_0"
state[buildEnv.tag]['containerName'] = "mysql"
break;
case "mariadb_10_3":