0d2dc2
#!/bin/sh
0d2dc2
0d2dc2
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
0d2dc2
0d2dc2
upgrade_info_file="$datadir/mysql_upgrade_info"
0d2dc2
version=0
0d2dc2
# get version as integer from mysql_upgrade_info file
0d2dc2
if [ -f "$upgrade_info_file" ] && [ -r "$upgrade_info_file" ] ; then
0d2dc2
    version_major=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\1/')
0d2dc2
    version_minor=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\2/')
0d2dc2
    if [[ $version_major =~ ^[0-9]+$ ]] && [[ $version_minor =~ ^[0-9]+$ ]] ; then
0d2dc2
        version=$((version_major*100+version_minor))
0d2dc2
    fi
0d2dc2
fi
0d2dc2
0d2dc2
# compute current version as integer
0d2dc2
thisversion=$((@MAJOR_VERSION@*100+@MINOR_VERSION@))
0d2dc2
0d2dc2
# provide warning in cases we should run mysql_upgrade
0d2dc2
if [ $version -ne $thisversion ] ; then
0d2dc2
0d2dc2
    # give extra warning if some version seems to be skipped
0d2dc2
    if [ $version -gt 0 ] && [ $version -lt 505 ] ; then
0d2dc2
        echo "The datadir located at $datadir seems to be older than of a version 5.5. Please, mind that as a general rule, to upgrade from one release series to another, go to the next series rather than skipping a series." >&2
0d2dc2
    fi
0d2dc2
0d2dc2
    cat <<EOF >&2
0d2dc2
The datadir located at $datadir needs to be upgraded using 'mysql_upgrade' tool. This can be done using the following steps:
0d2dc2
0d2dc2
  1. Back-up your data before with 'mysql_upgrade'
0d2dc2
  2. Start the database daemon using 'service @DAEMON_NAME@ start'
0d2dc2
  3. Run 'mysql_upgrade' with a database user that has sufficient privileges
0d2dc2
0d2dc2
Read more about 'mysql_upgrade' usage at:
0d2dc2
https://mariadb.com/kb/en/mariadb/documentation/sql-commands/table-commands/mysql_upgrade/
0d2dc2
EOF
0d2dc2
fi
0d2dc2
0d2dc2
exit 0