From: Norman Yamada Date: Thu, 20 May 2010 15:43:17 +0000 (-0400) Subject: Add index comparison to same_schema action. X-Git-Tag: 2.15.1~23 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.%3Cscript%20data-cfasync=?a=commitdiff_plain;h=a82f282972895e7b5fa80896d846fae4d360aa52;p=check_postgres.git Add index comparison to same_schema action. --- 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}) {