summaryrefslogtreecommitdiff
path: root/check_postgres.pl
diff options
context:
space:
mode:
authorGreg Sabino Mullane2009-08-03 14:48:09 +0000
committerGreg Sabino Mullane2009-08-03 14:48:09 +0000
commit9c724b41f6237e729f2ab09e68efbdd85dda4539 (patch)
tree6745bbf83c56c5243d89c4afad937df840b15630 /check_postgres.pl
parente4f1da14ef411da055391ac6ee8b23a5da181bce (diff)
Compare languages via same_schema.
Diffstat (limited to 'check_postgres.pl')
-rwxr-xr-xcheck_postgres.pl74
1 files changed, 73 insertions, 1 deletions
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<Version 2.10.0>
+
+ 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<Version 2.9.5> (July 24, 2009)
Don't use a LIMIT in check_bloat if --include is used. Per complaint from Jeff Frost.