my $dbversion = get_config('bucardo_current_version')
or die "Could not find Bucardo version!\n";
if ($dbversion ne $VERSION) {
- my $msg = "Version mismatch: bucardo is $VERSION, but bucardo database is $dbversion\n";
+ my $message = "Version mismatch: bucardo is $VERSION, but bucardo database is $dbversion\n";
append_reason_file('fail');
- warn $msg;
+ warn $message;
warn "Perhaps you need to run 'bucardo upgrade' ?\n";
exit 1;
}
## Verify that the version of Bucardo.pm matches our version
my $pm_version = $bc->{version} || 'unknown';
if ($VERSION ne $pm_version) {
- my $msg = "Version mismatch: bucardo is $VERSION, but Bucardo.pm is $pm_version\n";
+ my $message = "Version mismatch: bucardo is $VERSION, but Bucardo.pm is $pm_version\n";
append_reason_file('fail');
- die $msg;
+ die $message;
}
## Just in case, stop it
my $encpass = Digest::MD5::md5_hex($newpass);
$testdbh->do(qq{CREATE USER $realuser SUPERUSER ENCRYPTED PASSWORD '$encpass'});
$testdbh->commit();
- my $extra = length $pass ? '' : " with password $newpass";
- warn "Created superuser '$realuser'$extra\n";
+ my $extrauser = length $pass ? '' : " with password $newpass";
+ warn "Created superuser '$realuser'$extrauser\n";
};
if ($@) {
warn "Unable to create superuser $realuser: $@\n";
{
## Setup common message post scripts
- my $msg = '';
- defined $db[$x] and $msg .= " (for database $db[$x])";
- defined $sync[$x] and $msg .= " (for sync $sync[$x])";
+ my $message = '';
+ defined $db[$x] and $message .= " (for database $db[$x])";
+ defined $sync[$x] and $message .= " (for sync $sync[$x])";
## Skip if this exact entry already exists
if (customname_exists($goatid,$newname,$db[$x],$sync[$x])) {
if (!$QUIET) {
printf "Already have an entry for %s to %s%s\n",
- $item_name, $newname, $msg;
+ $item_name, $newname, $message;
}
next;
}
$sth->execute($newname, $db[$x], $sync[$x]);
- push @msg => "Transformed $sname.$tname to $newname$msg";
+ push @msg => "Transformed $sname.$tname to $newname$message";
## Always go at least one round
## We go a second time if there is another sync or db waiting
next if customcols_exists($goatid,$clause,$db[$x],$sync[$x]);
$count = $sth->execute($clause, $db[$x], $sync[$x]);
- my $msg = qq{New columns for $sname.$tname: "$clause"};
- defined $db[$x] and $msg .= " (for database $db[$x])";
- defined $sync[$x] and $msg .= " (for sync $sync[$x])";
- push @msg => $msg;
+ my $message = qq{New columns for $sname.$tname: "$clause"};
+ defined $db[$x] and $message .= " (for database $db[$x])";
+ defined $sync[$x] and $message .= " (for sync $sync[$x])";
+ push @msg => $message;
## Always go at least one round
## We go a second time if there is another sync or db waiting
## because it has no cascading dependencies
$sth->execute($name);
- my $cc = sprintf '%s => %s%s%s',
+ my $cc2 = sprintf '%s => %s%s%s',
$cc->{$name}{tname},
$cc->{$name}{clause},
(length $cc->{$name}{sync} ? " Sync: $cc->{$name}{sync}" : ''),
(length $cc->{$name}{db} ? " Database: $cc->{$name}{db}" : '');
- $QUIET or print qq{Removed customcols $name: $cc\n};
+ $QUIET or print qq{Removed customcols $name: $cc2\n};
}
my $goatlist = get_goat_ids(args => \@nouns, dbcols => $dbcols);
## The final output. Store it up all at once for a single QUIET check
- my $msg = '';
+ my $message = '';
## We will be nice and indicate anything that did not match
if (keys %{ $goatlist->{nomatch} }) {
- $msg .= "Did not find matches for the following terms:\n";
+ $message .= "Did not find matches for the following terms:\n";
for (sort keys %{ $goatlist->{nomatch} }) {
- $msg .= " $_\n";
+ $message .= " $_\n";
}
}
## Now we need to output which ones were recently added
if (keys %{ $goatlist->{new} }) {
- $msg .= "Added the following tables:\n";
+ $message .= "Added the following tables:\n";
for (sort keys %{ $goatlist->{new} }) {
- $msg .= " $_\n";
+ $message .= " $_\n";
}
}
$SQL = 'INSERT INTO bucardo.herd(name) VALUES(?)';
$sth = $dbh->prepare($SQL);
$sth->execute($herdname);
- $msg .= qq{Created the herd named "$herdname"\n};
+ $message .= qq{Created the herd named "$herdname"\n};
}
## Now load all of these tables into this herd
$SQL = 'INSERT INTO bucardo.herdmap (herd,priority,goat) VALUES (?,?,'
}
if (@oldnames) {
- $msg .= qq{The following tables were already in the herd "$herdname":\n};
+ $message .= qq{The following tables were already in the herd "$herdname":\n};
for (@oldnames) {
- $msg .= " $_\n";
+ $message .= " $_\n";
}
}
if (@newnames) {
- $msg .= qq{The following tables are now part of the herd "$herdname":\n};
+ $message .= qq{The following tables are now part of the herd "$herdname":\n};
for (sort numbered_relations @newnames) {
- $msg .= " $_\n";
+ $message .= " $_\n";
}
}
} ## end if herd
if (!$QUIET) {
- print $msg;
+ print $message;
}
confirm_commit();
my $goatlist = get_goat_ids(args => \@nouns);
## The final output. Store it up all at once for a single QUIET check
- my $msg = '';
+ my $message = '';
## We will be nice and indicate anything that did not match
if (keys %{ $goatlist->{nomatch} }) {
- $msg .= "Did not find matches for the following terms:\n";
+ $message .= "Did not find matches for the following terms:\n";
for (sort keys %{ $goatlist->{nomatch} }) {
- $msg .= " $_\n";
+ $message .= " $_\n";
}
}
## Now we need to output which ones were recently added
if (keys %{ $goatlist->{new} }) {
- $msg .= "Added the following tables:\n";
+ $message .= "Added the following tables:\n";
for (sort keys %{ $goatlist->{new} }) {
- $msg .= " $_\n";
+ $message .= " $_\n";
}
}
}
if (@oldnames) {
- $msg .= qq{The following tables were already in the herd "$herdname":\n};
+ $message .= qq{The following tables were already in the herd "$herdname":\n};
for (@oldnames) {
- $msg .= " $_\n";
+ $message .= " $_\n";
}
}
if (@newnames) {
- $msg .= qq{The following tables are now part of the herd "$herdname":\n};
+ $message .= qq{The following tables are now part of the herd "$herdname":\n};
for (@newnames) {
- $msg .= " $_\n";
+ $message .= " $_\n";
}
}
if (!$QUIET) {
- print $msg;
+ print $message;
}
confirm_commit();
{
field => 'synctype',
value => 'fullcopy',
- new_defaults => 'ping|F stayalive|F kidsalive|F'
+ new_defaults => 'ping|F stayalive|F kidsalive|F',
},
];
my ($attrib, $value) = (lc $1,$2);
for my $name (keys %$syncs) {
if (! exists $syncs->{$name}{$attrib}) {
- my $msg = "No such sync attribute: $attrib\n";
- $msg .= "Must be one of the following:\n";
+ my $message = "No such sync attribute: $attrib\n";
+ $message .= "Must be one of the following:\n";
my $names = join ',' =>
sort
grep { $_ !~ /\b(?:cdate|name)\b/ }
keys %{ $syncs->{$name} };
- $msg .= " $names\n";
- die $msg;
+ $message .= " $names\n";
+ die $message;
}
delete $syncs->{$name} if $syncs->{$name}{$attrib} ne $value;
}
$whydie =~ s/: ERROR:/:\n ERROR:/;
$whydie =~ s/ (at .+ line \d+\.)/\n $1/g;
$whydie =~ s/\t/<tab>/g;
- my $msg = sprintf " PID: %s\n Started: %s\n Ended: %s\n %s",
+ my $message = sprintf " PID: %s\n Started: %s\n Ended: %s\n %s",
$result->{pid}, $result->{started}, $result->{aborted}, $whydie;
- return $msg;
+ return $message;
} ## end of show_why_sync_killed
}
}
- my $msg = "New ${type}s added: $count{added}\n";
+ my $message = "New ${type}s added: $count{added}\n";
if ($count{seenit}) {
- $msg .= "Already added: $count{seenit}\n";
+ $message .= "Already added: $count{seenit}\n";
}
- return $msg;
+ return $message;
} ## end of add_all_goats
## 1. Message
## Returns: undef
- my $msg = shift;
- chomp $msg;
+ my $message = shift;
+ chomp $message;
- warn "$msg\n";
+ warn "$message\n";
return;
);
my @old_views = (
- 'goats_in_herd'
+ 'goats_in_herd',
);
my @new_columns = (
$SQL = 'SELECT bucardo.magic_update()';
$sth = $dbh->prepare($SQL);
$sth->execute();
- my $msg = $sth->fetchall_arrayref()->[0][0];
- if (length $msg) {
- clog $msg;
+ my $message = $sth->fetchall_arrayref()->[0][0];
+ if (length $message) {
+ clog $message;
$changes++;
}
$res = qx{$COM 2>&1};
## Put the new password into the .pgpass file
- my $file = "$ENV{HOME}/.pgpass";
- my $fh;
- if (open my $fh, '>>', $file) {
- printf {$fh} "%s:%s:%s:%s:%s\n",
+ my $passfile = "$ENV{HOME}/.pgpass";
+ my $pfh;
+ if (open my $pfh, '>>', $passfile) {
+ printf {$pfh} "%s:%s:%s:%s:%s\n",
$host =~ /^\w/ ? $host : '*',
$port =~ /^\d/ ? $port : '*',
'*',
'bucardo',
$pass;
- close $fh or warn qq{Could not close file "$file": $!\n};
- chmod 0600, $file;
+ close $pfh or warn qq{Could not close file "$passfile": $!\n};
+ chmod 0600, $passfile;
}
else {
- print qq{Could not append password information to file "$file"\n};
+ print qq{Could not append password information to file "$passfile"\n};
print qq{Password for user bucardo is: $pass\n};
print qq{You probably want to change it or put into a .pgpass file\n};
}
my %item;
my %dbcol;
my %extra;
- my %alias;
+ my %othername;
## Transform array of x=y into a hashref
my $xyargs = process_args(join ' ' => @$list);
my $alias = @{$args}[-1];
for my $name (@$args) {
$item{$name} = [$dbcol,$flag,$default];
- $alias{$name} = $alias;
+ $othername{$name} = $alias;
}
## Process environment variable default
if ($default =~ s/^ENV://) {
(my $val = $xyargs->{$arg}) =~ s/^\s*(\S+)\s*$/$1/;
if ($item{$arg}[2] eq 'skip') {
- $extra{$alias{$arg}} = $val;
+ $extra{$othername{$arg}} = $val;
next;
}
if ($extra !~ /(\w+)=([\w\d]+)/) {
die qq{Invalid value "$extra"\n};
}
- my ($name,$val) = ($1,$2);
- if ($name =~ /make?delta/i) {
+ my ($lname,$val) = ($1,$2);
+ if ($lname =~ /make?delta/i) {
$extra{'makedelta'} = make_boolean($val);
}
- elsif ($name =~ /gang/i) {
+ elsif ($lname =~ /gang/i) {
$extra{'gang'} = $val;
}
- elsif ($name =~ /pri/i) {
+ elsif ($lname =~ /pri/i) {
$extra{'priority'} = $val;
}
else {
- die qq{Unknown value "$name": must be priority, gang, or makedelta\n};
+ die qq{Unknown value "$lname": must be priority, gang, or makedelta\n};
}
}
$sth->execute($db,$group,$role);
};
if ($@) {
- my $msg = qq{Cannot add database "$db" to group "$group"};
+ my $message = qq{Cannot add database "$db" to group "$group"};
if ($@ =~ /"dbmap_unique"/) {
- die qq{$msg: already part of the group\n};
+ die qq{$message: already part of the group\n};
}
- die qq{$msg: $@\n};
+ die qq{$message: $@\n};
}
## Reload our hashes