Skip to content

Commit 735dc1a

Browse files
committed
genbki stricter error handling
Instead of just writing warnings for invalid cross-catalog lookups, count the errors and error out at the end. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/ca8ee41d-241b-1bf3-71f0-aaf1add6d3c5%40enterprisedb.com
1 parent ab5e48f commit 735dc1a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/backend/catalog/genbki.pl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
my $major_version;
2727
my $include_path;
2828

29+
my $num_errors = 0;
30+
2931
GetOptions(
3032
'output:s' => \$output_path,
3133
'set-version:s' => \$major_version,
@@ -796,7 +798,7 @@
796798
Catalog::RenameTempFile($fk_info_file, $tmpext);
797799
Catalog::RenameTempFile($constraints_file, $tmpext);
798800

799-
exit 0;
801+
exit ($num_errors != 0 ? 1 : 0);
800802

801803
#################### Subroutines ########################
802804

@@ -1024,8 +1026,7 @@ sub morph_row_for_schemapg
10241026
# Perform OID lookups on an array of OID names.
10251027
# If we don't have a unique value to substitute, warn and
10261028
# leave the entry unchanged.
1027-
# (A warning seems sufficient because the bootstrap backend will reject
1028-
# non-numeric values anyway. So we might as well detect multiple problems
1029+
# (We don't exit right away so that we can detect multiple problems
10291030
# within this genbki.pl run.)
10301031
sub lookup_oids
10311032
{
@@ -1045,16 +1046,20 @@ sub lookup_oids
10451046
push @lookupoids, $lookupname;
10461047
if ($lookupname eq '-' or $lookupname eq '0')
10471048
{
1048-
warn sprintf
1049-
"invalid zero OID reference in %s.dat field %s line %s\n",
1050-
$catname, $attname, $bki_values->{line_number}
1051-
if !$lookup_opt;
1049+
if (!$lookup_opt)
1050+
{
1051+
warn sprintf
1052+
"invalid zero OID reference in %s.dat field %s line %s\n",
1053+
$catname, $attname, $bki_values->{line_number};
1054+
$num_errors++;
1055+
}
10521056
}
10531057
else
10541058
{
10551059
warn sprintf
10561060
"unresolved OID reference \"%s\" in %s.dat field %s line %s\n",
10571061
$lookupname, $catname, $attname, $bki_values->{line_number};
1062+
$num_errors++;
10581063
}
10591064
}
10601065
}

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