mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
Remove mysqldump prompt, add --all-databases, and make --databases or --all-databases required to do mysqldump (Schema section).
This commit is contained in:
@@ -963,7 +963,7 @@ get_mysqldump_for () {
|
|||||||
$CMD_MYSQLDUMP $EXT_ARGV --no-data --skip-comments \
|
$CMD_MYSQLDUMP $EXT_ARGV --no-data --skip-comments \
|
||||||
--skip-add-locks --skip-add-drop-table --compact \
|
--skip-add-locks --skip-add-drop-table --compact \
|
||||||
--skip-lock-all-tables --skip-lock-tables --skip-set-charset \
|
--skip-lock-all-tables --skip-lock-tables --skip-set-charset \
|
||||||
${args} --databases $( local IFS=,; echo ${dbtodump})
|
${args} --databases $(local IFS=,; echo ${dbtodump})
|
||||||
}
|
}
|
||||||
|
|
||||||
get_mysqldump_args () {
|
get_mysqldump_args () {
|
||||||
@@ -2243,24 +2243,14 @@ report_mysql_summary () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
section "Schema"
|
section "Schema"
|
||||||
local reply="n"
|
if [ "${OPT_DATABASES}" ] \
|
||||||
if [ "${OPT_DATABASES}" ] || [ "${OPT_READ_SAMPLES}" ] \
|
|| [ "${OPT_ALL_DATABASES}" ] \
|
||||||
|| [ -e "$dir/mysqldump" -a -s "$dir/mysqldump" ]; then
|
|| [ "${OPT_READ_SAMPLES}" ]; then
|
||||||
reply="y"
|
|
||||||
elif [ -t 0 -a -t 1 ]; then
|
if [ -z "$OPT_READ_SAMPLES" ]; then
|
||||||
echo -n "Would you like to mysqldump -d the schema and analyze it? y/n "
|
local trg_arg="$(get_mysqldump_args "$dir/mysql-variables")"
|
||||||
read reply
|
local dbstodump="${OPT_DATABASES:-""}"
|
||||||
reply=${reply:-n}
|
get_mysqldump_for "${trg_arg}" "${OPT_DATABASES}" > "$dir/mysqldump"
|
||||||
fi
|
|
||||||
if echo "${reply:-n}" | grep -i '^y' > /dev/null ; then
|
|
||||||
if [ -z "${OPT_DATABASES}" ] && [ -z "$OPT_READ_SAMPLES" ] \
|
|
||||||
&& [ ! -e "$dir/mysqldump" ]; then
|
|
||||||
echo "There are ${num_dbs} databases. Would you like to dump all, or just one?"
|
|
||||||
echo -n "Type the name of the database, or press Enter to dump all of them. "
|
|
||||||
local dbtodump=""
|
|
||||||
read dbtodump
|
|
||||||
local trg_arg="$( get_mysqldump_args "$dir/mysql-variables" )"
|
|
||||||
get_mysqldump_for "${trg_arg}" "${dbtodump}" > "$dir/mysqldump"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$dir/mysqldump" -a -s "$dir/mysqldump" ] \
|
if [ -e "$dir/mysqldump" -a -s "$dir/mysqldump" ] \
|
||||||
@@ -2273,7 +2263,7 @@ report_mysql_summary () {
|
|||||||
echo "Skipping schema analysis due to apparent error in dump file"
|
echo "Skipping schema analysis due to apparent error in dump file"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Skipping schema analysis"
|
echo "Specify --databases or --all-databases to dump and summarize schemas"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
section "Noteworthy Technologies"
|
section "Noteworthy Technologies"
|
||||||
@@ -2731,10 +2721,6 @@ the percentage of the cache in use and the hit-to-insert ratio. The latter two
|
|||||||
are fuzzy-rounded.
|
are fuzzy-rounded.
|
||||||
|
|
||||||
# Schema #####################################################
|
# Schema #####################################################
|
||||||
Would you like to mysqldump -d the schema and analyze it? y/n y
|
|
||||||
There are 4 databases. Would you like to dump all, or just one?
|
|
||||||
Type the name of the database, or press Enter to dump all of them.
|
|
||||||
|
|
||||||
Database Tables Views SPs Trigs Funcs FKs Partn
|
Database Tables Views SPs Trigs Funcs FKs Partn
|
||||||
mysql 24
|
mysql 24
|
||||||
performance_schema 17
|
performance_schema 17
|
||||||
@@ -2765,16 +2751,10 @@ are fuzzy-rounded.
|
|||||||
performance_schema 5 16 33
|
performance_schema 5 16 33
|
||||||
sakila 1 15 1 3 4 3 19 42 26
|
sakila 1 15 1 3 4 3 19 42 26
|
||||||
|
|
||||||
If you select to dump the schema and analyze it, the tool will print the above
|
If you specify L<"--databases"> or L<"--all-databases">, the tool will print
|
||||||
section. This summarizes the number and type of objects in the database. It is
|
the above section. This summarizes the number and type of objects in the
|
||||||
generated by running C<mysqldump --no-data>, not by querying the
|
databases. It is generated by running C<mysqldump --no-data>, not by querying
|
||||||
INFORMATION_SCHEMA, which can freeze a busy server. You can use the
|
the INFORMATION_SCHEMA, which can freeze a busy server.
|
||||||
L<"--databases"> option to specify which databases to examine. If you do not,
|
|
||||||
and you run the tool interactively, it will prompt you as shown.
|
|
||||||
|
|
||||||
You can choose not to dump the schema, to dump all of the databases, or to dump
|
|
||||||
only a single named one, by specifying the appropriate options. In the example
|
|
||||||
above, we are dumping all databases.
|
|
||||||
|
|
||||||
The first sub-report in the section is the count of objects by type in each
|
The first sub-report in the section is the count of objects by type in each
|
||||||
database: tables, views, and so on. The second one shows how many tables use
|
database: tables, views, and so on. The second one shows how many tables use
|
||||||
@@ -2949,6 +2929,10 @@ All options after -- are passed to C<mysql>.
|
|||||||
|
|
||||||
=over
|
=over
|
||||||
|
|
||||||
|
=item --all-databases
|
||||||
|
|
||||||
|
C<mysqldump> and summarize all L<"--databases">.
|
||||||
|
|
||||||
=item --config
|
=item --config
|
||||||
|
|
||||||
type: string
|
type: string
|
||||||
@@ -2960,9 +2944,8 @@ first option on the command line.
|
|||||||
|
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
Names of databases to summarize. If you want all of them, you can use the value
|
C<mysqldump> and summarize this comma-separated list of databases. Specify
|
||||||
C<--all-databases>; you can also pass in a comma-separated list of database
|
L<"--all-databases"> instead if you want to dump and summary all databases.
|
||||||
names. If not provided, the program will ask you for manual input.
|
|
||||||
|
|
||||||
=item --defaults-file
|
=item --defaults-file
|
||||||
|
|
||||||
|
@@ -168,7 +168,7 @@ get_mysqldump_for () {
|
|||||||
$CMD_MYSQLDUMP $EXT_ARGV --no-data --skip-comments \
|
$CMD_MYSQLDUMP $EXT_ARGV --no-data --skip-comments \
|
||||||
--skip-add-locks --skip-add-drop-table --compact \
|
--skip-add-locks --skip-add-drop-table --compact \
|
||||||
--skip-lock-all-tables --skip-lock-tables --skip-set-charset \
|
--skip-lock-all-tables --skip-lock-tables --skip-set-charset \
|
||||||
${args} --databases $( local IFS=,; echo ${dbtodump})
|
${args} --databases $(local IFS=,; echo ${dbtodump})
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns a string with arguments to pass to mysqldump.
|
# Returns a string with arguments to pass to mysqldump.
|
||||||
|
@@ -1318,29 +1318,15 @@ report_mysql_summary () {
|
|||||||
# Schema, databases, data type, other analysis.
|
# Schema, databases, data type, other analysis.
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
section "Schema"
|
section "Schema"
|
||||||
# Assume "no" if stdin or stdout is not a terminal, so this can be run and
|
if [ "${OPT_DATABASES}" ] \
|
||||||
# put into a file, or piped into a pager, or something else like that.
|
|| [ "${OPT_ALL_DATABASES}" ] \
|
||||||
local reply="n"
|
|| [ "${OPT_READ_SAMPLES}" ]; then
|
||||||
# But dump no matter what if they passed in something through --databases,
|
|
||||||
# OR if --read-samples was set
|
if [ -z "$OPT_READ_SAMPLES" ]; then
|
||||||
if [ "${OPT_DATABASES}" ] || [ "${OPT_READ_SAMPLES}" ] \
|
# --databases or --all-databases was specified
|
||||||
|| [ -e "$dir/mysqldump" -a -s "$dir/mysqldump" ]; then
|
local trg_arg="$(get_mysqldump_args "$dir/mysql-variables")"
|
||||||
reply="y"
|
local dbstodump="${OPT_DATABASES:-""}"
|
||||||
elif [ -t 0 -a -t 1 ]; then
|
get_mysqldump_for "${trg_arg}" "${OPT_DATABASES}" > "$dir/mysqldump"
|
||||||
echo -n "Would you like to mysqldump -d the schema and analyze it? y/n "
|
|
||||||
read reply
|
|
||||||
reply=${reply:-n}
|
|
||||||
fi
|
|
||||||
if echo "${reply:-n}" | grep -i '^y' > /dev/null ; then
|
|
||||||
if [ -z "${OPT_DATABASES}" ] && [ -z "$OPT_READ_SAMPLES" ] \
|
|
||||||
&& [ ! -e "$dir/mysqldump" ]; then
|
|
||||||
# If --dump-schemas wasn't used, ask what they want to dump
|
|
||||||
echo "There are ${num_dbs} databases. Would you like to dump all, or just one?"
|
|
||||||
echo -n "Type the name of the database, or press Enter to dump all of them. "
|
|
||||||
local dbtodump=""
|
|
||||||
read dbtodump
|
|
||||||
local trg_arg="$( get_mysqldump_args "$dir/mysql-variables" )"
|
|
||||||
get_mysqldump_for "${trg_arg}" "${dbtodump}" > "$dir/mysqldump"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test the result by checking the file, not by the exit status, because we
|
# Test the result by checking the file, not by the exit status, because we
|
||||||
@@ -1356,7 +1342,7 @@ report_mysql_summary () {
|
|||||||
echo "Skipping schema analysis due to apparent error in dump file"
|
echo "Skipping schema analysis due to apparent error in dump file"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Skipping schema analysis"
|
echo "Specify --databases or --all-databases to dump and summarize schemas"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
|
Reference in New Issue
Block a user