[check_postgres] check_postgres_replicate_row - allow odd table and column names

Glyn Astill glynastill at yahoo.co.uk
Wed Oct 1 15:47:12 UTC 2008


Hi Chaps,

We have a few oddly named tables (e.g. containing dashes etc) from the legacy side of our system and I couldn't check them with replicate row.

I made a change the the regex and quoted them. I'm sure theres probably a more elegant way of doing this, but here is what I did.



*** check_postgres.pl.orig5	2008-10-01 16:29:32.000000000 +0100
--- check_postgres.pl	2008-10-01 16:37:50.000000000 +0100
***************
*** 3328,3338 ****
  	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 ($table,$pk,$id,$col,$val1,$val2) = ($1,$2,$3,$4,$5,$6);
  
  	if ($val1 eq $val2) {
  	  ndie 'Makes no sense to test replication with same values';
  	}
--- 3328,3346 ----
  	if (!$opt{repinfo}) {
  		die "Need a repinfo argument\n";
  	}
! 
! 	## Glyn - changed to allow anything for table and column names - is there a better way?
! 	## if ($opt{repinfo} !~ m{(\w+),(\w+),(\w+),(\w+),(.*),(.+)}) {
! 	if ($opt{repinfo} !~ m{(.*),(.*),(\w+),(.*),(.*),(.+)}) {
  		die "Invalid value for repinfo argument\n";
  	}
  	my ($table,$pk,$id,$col,$val1,$val2) = ($1,$2,$3,$4,$5,$6);
  
+ 	## Glyn - double quote relaxed names 
+ 	$table = '"' . $table . '"';
+ 	$pk = '"' . $pk . '"';
+ 	$col = '"' . $col . '"';
+ 	
  	if ($val1 eq $val2) {
  	  ndie 'Makes no sense to test replication with same values';
  	}


      


More information about the Check_postgres mailing list