Applied the push request.

Thanks to aleksey-hariton.
This commit is contained in:
garnier-quentin 2015-04-26 21:09:09 +02:00
parent b084c26a5f
commit c0e409e4bb
2 changed files with 11 additions and 0 deletions

View File

@ -64,6 +64,7 @@ sub new {
"port:s@" => { name => 'port' },
"username:s@" => { name => 'username' },
"password:s@" => { name => 'password' },
"socket:s@" => { name => 'socket' },
"sql-errors-exit:s" => { name => 'sql_errors_exit', default => 'unknown' },
});
}
@ -78,6 +79,7 @@ sub new {
$self->{host} = undef;
$self->{port} = undef;
$self->{socket} = undef;
$self->{username} = undef;
$self->{password} = undef;
@ -118,6 +120,7 @@ sub check_options {
$self->{host} = (defined($self->{option_results}->{host})) ? shift(@{$self->{option_results}->{host}}) : undef;
$self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : undef;
$self->{socket} = (defined($self->{option_results}->{socket})) ? shift(@{$self->{option_results}->{socket}}) : undef;
$self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : undef;
$self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : undef;
$self->{sql_errors_exit} = $self->{option_results}->{sql_errors_exit};
@ -138,6 +141,9 @@ sub check_options {
if (defined($self->{password}) && $self->{password} ne '') {
push @{$self->{args}}, "-p" . $self->{password};
}
if (defined($self->{socket}) && $self->{socket} ne '') {
push @{$self->{args}}, "--socket", $self->{socket};
}
if (scalar(@{$self->{option_results}->{host}}) == 0) {
return 0;

View File

@ -73,6 +73,7 @@ sub init {
arguments => {
'host:s@' => { name => 'db_host' },
'port:s@' => { name => 'db_port' },
'socket:s@' => { name => 'db_socket' },
}
);
$self->{options}->parse_options();
@ -89,6 +90,10 @@ sub init {
$self->{sqldefault}->{dbi}[$i]->{data_source} .= ';port=' . $options_result->{db_port}[$i];
$self->{sqldefault}->{mysqlcmd}[$i]->{port} = $options_result->{db_port}[$i];
}
if (defined($options_result->{db_socket}[$i])) {
$self->{sqldefault}->{dbi}[$i]->{data_source} .= ';mysql_socket=' . $options_result->{db_socket}[$i];
$self->{sqldefault}->{mysqlcmd}[$i]->{socket} = $options_result->{db_socket}[$i];
}
}
}