Skip to content

Commit 90b97ee

Browse files
committed
Skip index differences if the table is missing
Show tablename for indexes
1 parent 44cf93c commit 90b97ee

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

check_postgres.pl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ package check_postgres;
13121312
SELECT c.*, i.*, nspname||'.'||relname AS name, quote_ident(rolname) AS owner,
13131313
quote_ident(relname) AS safename, quote_ident(nspname) AS schema,
13141314
spcname AS tablespace, amname,
1315-
pg_get_indexdef(c.oid) AS indexdef
1315+
pg_get_indexdef(c.oid) AS indexdef, indrelid::regclass::text AS tablename
13161316
FROM pg_class c
13171317
JOIN pg_roles r ON (r.oid = c.relowner)
13181318
JOIN pg_namespace n ON (n.oid = c.relnamespace)
@@ -7262,6 +7262,9 @@ sub check_same_schema {
72627262
## Show the list of the item, and a CSV of which databases have it and which don't
72637263
my $isthere = join ', ' => sort { $a<=>$b } keys %{ $e->{$name}{isthere} };
72647264
my $nothere = join ', ' => sort { $a<=>$b } keys %{ $e->{$name}{nothere} };
7265+
## Extra information (e.g. tablename) may be stuffed into the hash value
7266+
(my $extra) = values %{ $e->{$name}{isthere} };
7267+
$name .= " ($extra)" if length $extra > 1;
72657268
$msg .= sprintf "%s\n %-*s %s\n %-*s %s\n",
72667269
msg('ss-noexist', $pitem, $name),
72677270
$maxsize, $msg_exists,
@@ -7578,6 +7581,8 @@ sub schema_item_exists {
75787581

75797582
if (! exists $itemhash->{$db2}{$item_class}{$name}) {
75807583

7584+
my $one = '1';
7585+
75817586
## Special exception for columns: do not add if the table is non-existent
75827587
if ($item_class eq 'column') {
75837588
(my $tablename = $name) =~ s/(.+)\..+/$1/;
@@ -7591,8 +7596,16 @@ sub schema_item_exists {
75917596
next if ! exists $itemhash->{$db2}{table}{$tablename};
75927597
}
75937598

7594-
$nomatch{$name}{isthere}{$db1} = 1;
7595-
$nomatch{$name}{nothere}{$db2} = 1;
7599+
## Special exception for indexes: do not add if the table is non-existent
7600+
if ($item_class eq 'index') {
7601+
my $it = $itemhash->{$db1}{$item_class}{$name};
7602+
my $tablename = "$it->{tablename}";
7603+
next if ! exists $itemhash->{$db2}{table}{$tablename};
7604+
$one = $tablename;
7605+
}
7606+
7607+
$nomatch{$name}{isthere}{$db1} = $one;
7608+
$nomatch{$name}{nothere}{$db2} = $one;
75967609
}
75977610
}
75987611
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy