Repository navigation
Closed
Labels
for: backport-to-6.0.xIssues that will be back-ported to the 6.0.x linein: corerelated-to: ddl-scriptstype: bug
Milestone
Description
Bug description
The MariaDB migration script for upgrading from Spring Batch 5.2 to 6.0 uses the unsupported RENAME SEQUENCE statement:
RENAME SEQUENCE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ;MariaDB requires RENAME TABLE to rename a sequence. As a result, the migration fails with an SQL syntax error before BATCH_JOB_SEQ can be renamed.
Environment
- Spring Batch: 6.0 migration script
- Source schema: Spring Batch 5.2
- Database: MariaDB 11.8.2
- MariaDB JDBC driver
Steps to reproduce
- Start a MariaDB instance.
- Initialize the database with the Spring Batch 5.2 schema.
- Run org/springframework/batch/core/migration/6.0/migration-mariadb.sql.
- Observe that the migration fails.
org.opentest4j.AssertionFailedError: Unexpected exception thrown: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of file [.../org/springframework/batch/core/migration/6.0/migration-mariadb.sql]: RENAME SEQUENCE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ
at org.junit.jupiter.api.Assertions.assertDoesNotThrow(Assertions.java:3306)
at org.springframework.batch.core.repository.migration.MariaDbMigrationScriptIntegrationTests.migrationScriptShouldBeValid(MariaDbMigrationScriptIntegrationTests.java:51)
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of file [.../org/springframework/batch/core/migration/6.0/migration-mariadb.sql]: RENAME SEQUENCE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:293)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:54)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.execute(ResourceDatabasePopulator.java:269)
at org.springframework.batch.core.repository.migration.MariaDbMigrationScriptIntegrationTests.lambda$migrationScriptShouldBeValid$0(MariaDbMigrationScriptIntegrationTests.java:51)
at org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:52)
at org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:39)
... 2 more
Caused by: java.sql.SQLSyntaxErrorException: (conn=4) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SEQUENCE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ' at line 1
at org.mariadb.jdbc.export.ExceptionFactory.createException(ExceptionFactory.java:308)
at org.mariadb.jdbc.export.ExceptionFactory.create(ExceptionFactory.java:402)
at org.mariadb.jdbc.message.ClientMessage.readPacket(ClientMessage.java:196)
at org.mariadb.jdbc.client.impl.StandardClient.readPacket(StandardClient.java:1524)
at org.mariadb.jdbc.client.impl.StandardClient.readResults(StandardClient.java:1463)
at org.mariadb.jdbc.client.impl.StandardClient.readResponse(StandardClient.java:1382)
at org.mariadb.jdbc.client.impl.StandardClient.execute(StandardClient.java:1306)
at org.mariadb.jdbc.Statement.executeInternal(Statement.java:1003)
at org.mariadb.jdbc.Statement.execute(Statement.java:1132)
at org.mariadb.jdbc.Statement.execute(Statement.java:471)
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:261)
... 8 moreExpected behavior
The migration script should complete successfully and rename BATCH_JOB_SEQ to BATCH_JOB_INSTANCE_SEQ.
For MariaDB, the sequence should be renamed with:
RENAME TABLE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ;See: Table Operations that Work with Sequences
Minimal Complete Reproducible example
minimal complete verifiable example.
Metadata
Metadata
Assignees
Labels
for: backport-to-6.0.xIssues that will be back-ported to the 6.0.x linein: corerelated-to: ddl-scriptstype: bug
Activity
Fix MariaDB sequence rename in 6.0 migration
Fix MariaDB sequence rename in 6.0 migration