From a82f282972895e7b5fa80896d846fae4d360aa52 Mon Sep 17 00:00:00 2001 From: Norman Yamada Date: Thu, 20 May 2010 11:43:17 -0400 Subject: [PATCH] Add index comparison to same_schema action. --- check_postgres.pl | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/check_postgres.pl b/check_postgres.pl index 8bb4aced2..3b2c11558 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -5531,6 +5531,33 @@ JOIN pg_namespace n ON (n.oid = pronamespace) } } + ## Compare indexes + + ## Indexes on 1 but not 2 + INDEX1: + for my $name (sort keys %{$thing{1}{indexes}}) { + next if exists $thing{2}{indexes}{$name}; + for my $exclude (@{$opt{exclude}}) { + next INDEX1 if $name =~ /$exclude/; + } + + push @{$fail{indexes}{notexist}{1}} => $name; + $failcount++; + } + ## Indexes on 2 but not 1 + INDEX2: + for my $name (sort keys %{$thing{2}{indexes}}) { + for my $exclude (@{$opt{exclude}}) { + next INDEX2 if $name =~ /$exclude/; + } + + if (! exists $thing{1}{indexes}{$name}) { + push @{$fail{indexes}{notexist}{2}} => $name; + $failcount++; + next; + } + } + ## Compare columns ## Any columns on 1 but not 2, or 2 but not 1? @@ -6054,6 +6081,23 @@ JOIN pg_namespace n ON (n.oid = pronamespace) } } + ## Index differences + + if (exists $fail{indexes}){ + if (exists $fail{indexes}{notexist}) { + if (exists $fail{indexes}{notexist}{1}) { + for my $name (@{$fail{indexes}{notexist}{1}}) { + $db->{perf} .= " Index on 1 but not 2: $name "; + } + } + if (exists $fail{indexes}{notexist}{2}) { + for my $name (@{$fail{indexes}{notexist}{2}}) { + $db->{perf} .= " Index on 2 but not 1: $name "; + } + } + } + } + ## Column differences if (exists $fail{columns}) { if (exists $fail{columns}{notexist}) { -- 2.39.5