@@ -1312,7 +1312,7 @@ package check_postgres;
1312
1312
SELECT c.*, i.*, nspname||'.'||relname AS name, quote_ident(rolname) AS owner,
1313
1313
quote_ident(relname) AS safename, quote_ident(nspname) AS schema,
1314
1314
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
1316
1316
FROM pg_class c
1317
1317
JOIN pg_roles r ON (r.oid = c.relowner)
1318
1318
JOIN pg_namespace n ON (n.oid = c.relnamespace)
@@ -7262,6 +7262,9 @@ sub check_same_schema {
7262
7262
# # Show the list of the item, and a CSV of which databases have it and which don't
7263
7263
my $isthere = join ' , ' => sort { $a <=> $b } keys %{ $e -> {$name }{isthere } };
7264
7264
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;
7265
7268
$msg .= sprintf " %s \n %-*s %s \n %-*s %s \n " ,
7266
7269
msg(' ss-noexist' , $pitem , $name ),
7267
7270
$maxsize , $msg_exists ,
@@ -7578,6 +7581,8 @@ sub schema_item_exists {
7578
7581
7579
7582
if (! exists $itemhash -> {$db2 }{$item_class }{$name }) {
7580
7583
7584
+ my $one = ' 1' ;
7585
+
7581
7586
# # Special exception for columns: do not add if the table is non-existent
7582
7587
if ($item_class eq ' column' ) {
7583
7588
(my $tablename = $name ) =~ s / (.+)\. .+/ $1 / ;
@@ -7591,8 +7596,16 @@ sub schema_item_exists {
7591
7596
next if ! exists $itemhash -> {$db2 }{table }{$tablename };
7592
7597
}
7593
7598
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 ;
7596
7609
}
7597
7610
}
7598
7611
}
0 commit comments