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