Files
percona-toolkit/sandbox/load-sakila-db
Brian Fraser fraserb@gmail.com 4e833f3df3 Minimal PXC compat
2012-10-15 13:53:37 -03:00

56 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
err() {
echo
for msg; do
echo $msg
done
exit_status=1
}
# ###########################################################################
# Sanity check the cmd line options.
# ###########################################################################
if [ $# -lt 1 ]; then
err "Usage: load-sakila-db PORT"
exit 1
fi
PORT=$1
if [ ! -d "/tmp/$PORT" ]; then
err "MySQL test server does not exist: /tmp/$PORT"
exit 1
fi
# ###########################################################################
# Sanity check the environment.
# ###########################################################################
if [ -z "$PERCONA_TOOLKIT_BRANCH" ]; then
err "PERCONA_TOOLKIT_BRANCH environment variable is not set."
exit 1
fi
if [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then
err "Invalid PERCONA_TOOLKIT_BRANCH directory: $PERCONA_TOOLKIT_BRANCH"
exit 1
fi
cd $PERCONA_TOOLKIT_BRANCH/sandbox
exit_status=0
/tmp/$PORT/use < sakila-db/sakila-schema.sql
exit_status=$((exit_status | $?))
# We can remove this once PXC's triggers can handle myisam tables
if [ "${2:-""}" = "cluster" ]; then
/tmp/$PORT/use -e "ALTER TABLE sakila.film_text DROP KEY idx_title_description"
/tmp/$PORT/use -e "ALTER TABLE sakila.film_text ENGINE = 'InnoDB'"
fi
/tmp/$PORT/use < sakila-db/sakila-data.sql
exit_status=$((exit_status | $?))
exit $exit_status