~percona-toolkit-dev/percona-toolkit/pt-stalk-iter-1-bug-1070434

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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