Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PT-2156 Fix tests for lib, part2 #650

Merged
merged 16 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/pt-archiver
Original file line number Diff line number Diff line change
Expand Up @@ -1923,13 +1923,15 @@ sub get_create_table {
eval { $href = $dbh->selectrow_hashref($show_sql); };
if ( my $e = $EVAL_ERROR ) {
PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

die $e;
}

PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

my ($key) = grep { m/create (?:table|view)/i } keys %$href;
if ( !$key ) {
Expand Down
2 changes: 1 addition & 1 deletion bin/pt-config-diff
Original file line number Diff line number Diff line change
Expand Up @@ -3818,7 +3818,7 @@ sub BUILDARGS {
if ( ($args->{line_width} || '') eq 'auto' ) {
die "Cannot auto-detect line width because the Term::ReadKey module "
. "is not installed" unless $have_term;
($args->{line_width}) = GetTerminalSize();
($args->{line_width}) = Term::ReadKey::GetTerminalSize();
PTDEBUG && _d('Line width:', $args->{line_width});
}

Expand Down
6 changes: 4 additions & 2 deletions bin/pt-duplicate-key-checker
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,15 @@ sub get_create_table {
eval { $href = $dbh->selectrow_hashref($show_sql); };
if ( my $e = $EVAL_ERROR ) {
PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

die $e;
}

PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

my ($key) = grep { m/create (?:table|view)/i } keys %$href;
if ( !$key ) {
Expand Down
6 changes: 4 additions & 2 deletions bin/pt-find
Original file line number Diff line number Diff line change
Expand Up @@ -1862,13 +1862,15 @@ sub get_create_table {
eval { $href = $dbh->selectrow_hashref($show_sql); };
if ( my $e = $EVAL_ERROR ) {
PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

die $e;
}

PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

my ($key) = grep { m/create (?:table|view)/i } keys %$href;
if ( !$key ) {
Expand Down
6 changes: 4 additions & 2 deletions bin/pt-heartbeat
Original file line number Diff line number Diff line change
Expand Up @@ -3603,13 +3603,15 @@ sub get_create_table {
eval { $href = $dbh->selectrow_hashref($show_sql); };
if ( my $e = $EVAL_ERROR ) {
PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

die $e;
}

PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

my ($key) = grep { m/create (?:table|view)/i } keys %$href;
if ( !$key ) {
Expand Down
6 changes: 4 additions & 2 deletions bin/pt-index-usage
Original file line number Diff line number Diff line change
Expand Up @@ -3114,13 +3114,15 @@ sub get_create_table {
eval { $href = $dbh->selectrow_hashref($show_sql); };
if ( my $e = $EVAL_ERROR ) {
PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

die $e;
}

PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

my ($key) = grep { m/create (?:table|view)/i } keys %$href;
if ( !$key ) {
Expand Down
19 changes: 15 additions & 4 deletions bin/pt-ioprofile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files
GLOBAL_CONFIG=0 # We ignore non-recognized options in global configs

usage() {
local file="$1"
Expand Down Expand Up @@ -203,9 +204,15 @@ parse_options() {
_parse_config_files "$user_config_file"
done
else
_parse_config_files "/etc/percona-toolkit/percona-toolkit.conf" "/etc/percona-toolkit/$TOOL.conf"
GLOBAL_CONFIG=1
_parse_config_files "/etc/percona-toolkit/percona-toolkit.conf"
GLOBAL_CONFIG=0
_parse_config_files "/etc/percona-toolkit/$TOOL.conf"
if [ "${HOME:-}" ]; then
_parse_config_files "$HOME/.percona-toolkit.conf" "$HOME/.$TOOL.conf"
GLOBAL_CONFIG=1
_parse_config_files "$HOME/.percona-toolkit.conf"
GLOBAL_CONFIG=0
_parse_config_files "$HOME/.$TOOL.conf"
svetasmirnova marked this conversation as resolved.
Show resolved Hide resolved
fi
fi

Expand Down Expand Up @@ -312,7 +319,7 @@ _parse_config_files() {

echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue

config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')"
config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/\s[ ]*#.*$//')"

[ "$config_opt" = "" ] && continue

Expand Down Expand Up @@ -404,7 +411,11 @@ _parse_command_line() {
else
spec=$(grep "^short form:-$opt\$" "$PT_TMPDIR"/po/* | cut -d ':' -f 1)
if [ -z "$spec" ]; then
continue
if [ $GLOBAL_CONFIG -eq 1 ]; then
continue
else
option_error "Unknown option: $real_opt"
fi
fi
fi

Expand Down
6 changes: 4 additions & 2 deletions bin/pt-kill
Original file line number Diff line number Diff line change
Expand Up @@ -2977,13 +2977,15 @@ sub get_create_table {
eval { $href = $dbh->selectrow_hashref($show_sql); };
if ( my $e = $EVAL_ERROR ) {
PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

die $e;
}

PTDEBUG && _d($old_sql_mode);
$dbh->do($old_sql_mode);
eval { $dbh->do($old_sql_mode); };
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);

my ($key) = grep { m/create (?:table|view)/i } keys %$href;
if ( !$key ) {
Expand Down
19 changes: 15 additions & 4 deletions bin/pt-mext
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files
GLOBAL_CONFIG=0 # We ignore non-recognized options in global configs

usage() {
local file="$1"
Expand Down Expand Up @@ -244,9 +245,15 @@ parse_options() {
_parse_config_files "$user_config_file"
done
else
_parse_config_files "/etc/percona-toolkit/percona-toolkit.conf" "/etc/percona-toolkit/$TOOL.conf"
GLOBAL_CONFIG=1
_parse_config_files "/etc/percona-toolkit/percona-toolkit.conf"
GLOBAL_CONFIG=0
_parse_config_files "/etc/percona-toolkit/$TOOL.conf"
if [ "${HOME:-}" ]; then
_parse_config_files "$HOME/.percona-toolkit.conf" "$HOME/.$TOOL.conf"
GLOBAL_CONFIG=1
_parse_config_files "$HOME/.percona-toolkit.conf"
GLOBAL_CONFIG=0
_parse_config_files "$HOME/.$TOOL.conf"
fi
fi

Expand Down Expand Up @@ -353,7 +360,7 @@ _parse_config_files() {

echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue

config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')"
config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/\s[ ]*#.*$//')"

[ "$config_opt" = "" ] && continue

Expand Down Expand Up @@ -445,7 +452,11 @@ _parse_command_line() {
else
spec=$(grep "^short form:-$opt\$" "$PT_TMPDIR"/po/* | cut -d ':' -f 1)
if [ -z "$spec" ]; then
continue
if [ $GLOBAL_CONFIG -eq 1 ]; then
continue
else
option_error "Unknown option: $real_opt"
fi
fi
fi

Expand Down
Loading