From 9c724b41f6237e729f2ab09e68efbdd85dda4539 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Mon, 3 Aug 2009 10:48:09 -0400 Subject: Compare languages via same_schema. --- check_postgres.pl | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'check_postgres.pl') diff --git a/check_postgres.pl b/check_postgres.pl index d5a0ec158..c01961a94 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -4625,7 +4625,23 @@ SQL }; } } - } + + ## Get a list of all languages + $SQL = q{SELECT lanname FROM pg_language}; + $info = run_command($SQL, { dbuser => $opt{dbuser}[$x-1], dbnumber => $x } ); + for $db (@{$info->{db}}) { + for my $line (split /\n/, $db->{slurp}) { + unless ($line =~ /^\s*(\w+)\s*/gmo) { + warn "Query processing failed:\n$line\nfrom $SQL\n"; + next; + } + my ($lang) = ($1); + $thing{$x}{language}{$lang} = 1; + } + } + + + } ## end each database to query $db = $saved_db; @@ -5134,6 +5150,22 @@ SQL } } + ## Compare languages + for my $name (sort keys %{$thing{1}{language}}) { + if (!exists $thing{2}{language}{$name}) { + push @{$fail{language}{notexist}{1}} => $name; + $failcount++; + next; + } + } + for my $name (sort keys %{$thing{2}{language}}) { + if (!exists $thing{1}{language}{$name}) { + push @{$fail{language}{notexist}{2}} => $name; + $failcount++; + next; + } + } + ## Compare functions ## Functions on 1 but not 2? @@ -5147,6 +5179,14 @@ SQL } } + ## Skip if these are a side effect of having a language + for my $lang (@{$fail{language}{notexist}{1}}) { + $lang =~ s/u$//; + next FUNCTION if + $name eq "pg_catalog.${lang}_call_handler()" + or $name eq "pg_catalog.${lang}_validator(oid)"; + } + push @{$fail{functions}{notexist}{1}} => $name; $failcount++; } @@ -5161,6 +5201,14 @@ SQL } } + ## Skip if these are a side effect of having a language + for my $lang (@{$fail{language}{notexist}{2}}) { + $lang =~ s/u$//; + next FUNCTION if + $name =~ "pg_catalog.${lang}_call_handler()" + or $name eq "pg_catalog.${lang}_validator(oid)"; + } + if (! exists $thing{1}{functions}{$name}) { push @{$fail{functions}{notexist}{2}} => $name; $failcount++; @@ -5196,6 +5244,7 @@ SQL } } + ## ## Comparison is done, let's report the results ## @@ -5546,6 +5595,23 @@ SQL } } + ## Language differences + if (exists $fail{language}) { + if (exists $fail{language}{notexist}) { + if (exists $fail{language}{notexist}{1}) { + for my $name (@{$fail{language}{notexist}{1}}) { + $db->{perf} .= " Language on 1 but not 2: $name "; + } + } + if (exists $fail{language}{notexist}{2}) { + for my $name (@{$fail{language}{notexist}{2}}) { + $db->{perf} .= " Language on 2 but not 1: $name "; + } + } + } + } + + add_critical msg('same-failed', $failcount); return; @@ -7491,6 +7557,12 @@ Items not specifically attributed are by Greg Sabino Mullane. =over 4 +=item B + + For same_schema, compare view definitions, and compare languages. + Make script into a global executable via the Makefile.PL file. + Better output when comparing two databases. + =item B (July 24, 2009) Don't use a LIMIT in check_bloat if --include is used. Per complaint from Jeff Frost. -- cgit v1.2.3