From: Greg Sabino Mullane Date: Wed, 1 Oct 2008 16:47:25 +0000 (-0400) Subject: Allow almost anything in --repinfo rather than just \w+. X-Git-Tag: 2.9.0~241 X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=ca8fba0e5132a19ee53cfec5edff1df108184b7d;p=check_postgres.git Allow almost anything in --repinfo rather than just \w+. Thanks to Glyn Astill for finding this limitation. --- diff --git a/check_postgres.pl b/check_postgres.pl index 88022bc71..677534189 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -3328,10 +3328,16 @@ sub check_replicate_row { if (!$opt{repinfo}) { die "Need a repinfo argument\n"; } - if ($opt{repinfo} !~ m{(\w+),(\w+),(\w+),(\w+),(.*),(.+)}) { - die "Invalid value for repinfo argument\n"; + my @repinfo = split /,/ => ($opt{repinfo} || ''); + if ($#repinfo != 5) { + die "Invalid repfino argument: expected 6 comma-separated values\n"; } - my ($table,$pk,$id,$col,$val1,$val2) = ($1,$2,$3,$4,$5,$6); + my ($table,$pk,$id,$col,$val1,$val2) = (@repinfo); + + ## Quote funky identifiers + $table = qq{"$table"} if $table !~ /^\w+$/; + $pk = qq{"$pk"} if $pk !~ /^\w+$/; + $col = qq{"$col"} if $col !~ /^\w+$/; if ($val1 eq $val2) { ndie 'Makes no sense to test replication with same values'; @@ -3349,7 +3355,7 @@ sub check_replicate_row { ## Squirrel away the $db setting for later my $sourcedb = $info1->{db}[0]; if (!defined $sourcedb) { - ndie 'Replication source row not found'; + ndie "Replication source row not found: $table.$col"; } (my $value1 = $info1->{db}[0]{slurp}) =~ s/^\s*(\S+)\s*$/$1/; @@ -4571,7 +4577,8 @@ Items not specifically attributed are by Greg Sabino Mullane. =item B - Documentaion tweaks. + Expand range of allowed names for --repinfo argument (Glyn Astill) + Documentation tweaks. =item B (September 30, 2008)