forked from sclorg/mariadb-container
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on the MYSQL_UPGRADE variable and based on the datadir version detected, we either warn user about incompatibilities, or run one of the specified tools: * mysql_upgrade * mysqlcheck --analyze --all-databases * mysqlcheck --optimize --all-databases This should also fix sclorg#33
- Loading branch information
Showing
7 changed files
with
255 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
10.1/root/usr/share/container-scripts/mysql/check-upgrade.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
check_datadir_version() { | ||
local datadir="$1" | ||
local datadir_version=$(get_datadir_version "$datadir") | ||
local mysqld_version=$(mysqld_compat_version) | ||
|
||
case "${MYSQL_UPGRADE}" in | ||
auto|warn) | ||
if [ "${datadir_version}" -eq "${mysqld_version}" ] ; then | ||
log_info 'MySQL server version check OK.' | ||
return 0 | ||
fi | ||
|
||
if [ $(( ${datadir_version} + 1 )) -eq "${mysqld_version}" -o "${datadir_version}" -eq 505 -a "${mysqld_version}" -eq 1000 ] ; then | ||
log_info "MySQL server is version '${mysqld_version}' and datadir is version '${datadir_version}'." | ||
if [ "${MYSQL_UPGRADE}" == 'auto' ] ; then | ||
log_info 'Running mysql_upgrade ...' | ||
mysql_upgrade --socket=/tmp/mysql.sock | ||
fi | ||
else | ||
log_info "MySQL server is version '${mysqld_version}' and datadir is version '${datadir_version}', which are incompatible." | ||
fi | ||
;; | ||
|
||
force) | ||
log_info 'Running mysql_upgrade --force ...' | ||
mysql_upgrade --socket=/tmp/mysql.sock --force | ||
;; | ||
|
||
optimize) | ||
log_info 'Running mysqlcheck --optimize --all-databases ...' | ||
mysqlcheck --socket=/tmp/mysql.sock --optimize --all-databases | ||
;; | ||
|
||
analyze) | ||
log_info 'Running mysqlcheck --analyze --all-databases ...' | ||
mysqlcheck --socket=/tmp/mysql.sock --analyze --all-databases | ||
;; | ||
*) | ||
log_info "Unknown value of MYSQL_UPGRADE variable: '${MYSQL_UPGRADE}', ignoring." | ||
;; | ||
esac | ||
} | ||
|
||
check_datadir_version "${MYSQL_DATADIR}" | ||
|
||
unset -f run_upgrade check_datadir_version | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters