Skip to content

Commit ad138a1

Browse files
committed
Merge pull request #1517 from shapeblue/mysql-5.7-upgradefix
engine/schema: fix upgrade path to work with MySQL 5.7Found this issue when using MySQL 5.7 with Ubuntu 16.04. The upgrade path fix removes an invalid `IGNORE` param that is deprecated now, in the upgrade path we run the alter statement to add an index only if it does not exist so we're good. For MySQL 5.7, we'll also need to update the docs at some point to include `server-id` along with other parameters. Some of the SQL statements used throughout engine/schema don't adhere to SQL 99 standard which is enforced by default in MySQL 5.7, therefore the following sql-mode (for backward compatibility with mysql 5.6 modes) will be necessary for anyone willing to use MySQL 5.7 (until we fix codebase wide raw and generated sql statements to be SQL99 compliant): sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION" server-id = 1 innodb_rollback_on_timeout=1 innodb_lock_wait_timeout=600 max_connections=350 log-bin=mysql-bin binlog-format = 'ROW' /cc @swill @jburwell @agneya2001 @wido @DaanHoogland and others * pr/1517: engine/schema: fix upgrade path to work with MySQL 5.7 Signed-off-by: Will Stevens <[email protected]>
2 parents 12d8e53 + c63ea0a commit ad138a1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ private void addHostDetailsIndex(Connection conn) {
12971297
s_logger.debug("Index already exists on host_details - not adding new one");
12981298
} else {
12991299
// add the index
1300-
try(PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER IGNORE TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id` (`host_id`)");) {
1300+
try(PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id` (`host_id`)");) {
13011301
pstmtUpdate.executeUpdate();
13021302
s_logger.debug("Index did not exist on host_details - added new one");
13031303
}catch (SQLException e) {

0 commit comments

Comments
 (0)