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
This commit is contained in:
parent
ab5e48f153
commit
735dc1a094
|
@ -26,6 +26,8 @@ my $output_path = '';
|
||||||
my $major_version;
|
my $major_version;
|
||||||
my $include_path;
|
my $include_path;
|
||||||
|
|
||||||
|
my $num_errors = 0;
|
||||||
|
|
||||||
GetOptions(
|
GetOptions(
|
||||||
'output:s' => \$output_path,
|
'output:s' => \$output_path,
|
||||||
'set-version:s' => \$major_version,
|
'set-version:s' => \$major_version,
|
||||||
|
@ -796,7 +798,7 @@ Catalog::RenameTempFile($schemafile, $tmpext);
|
||||||
Catalog::RenameTempFile($fk_info_file, $tmpext);
|
Catalog::RenameTempFile($fk_info_file, $tmpext);
|
||||||
Catalog::RenameTempFile($constraints_file, $tmpext);
|
Catalog::RenameTempFile($constraints_file, $tmpext);
|
||||||
|
|
||||||
exit 0;
|
exit ($num_errors != 0 ? 1 : 0);
|
||||||
|
|
||||||
#################### Subroutines ########################
|
#################### Subroutines ########################
|
||||||
|
|
||||||
|
@ -1024,8 +1026,7 @@ sub morph_row_for_schemapg
|
||||||
# Perform OID lookups on an array of OID names.
|
# Perform OID lookups on an array of OID names.
|
||||||
# If we don't have a unique value to substitute, warn and
|
# If we don't have a unique value to substitute, warn and
|
||||||
# leave the entry unchanged.
|
# leave the entry unchanged.
|
||||||
# (A warning seems sufficient because the bootstrap backend will reject
|
# (We don't exit right away so that we can detect multiple problems
|
||||||
# non-numeric values anyway. So we might as well detect multiple problems
|
|
||||||
# within this genbki.pl run.)
|
# within this genbki.pl run.)
|
||||||
sub lookup_oids
|
sub lookup_oids
|
||||||
{
|
{
|
||||||
|
@ -1045,16 +1046,20 @@ sub lookup_oids
|
||||||
push @lookupoids, $lookupname;
|
push @lookupoids, $lookupname;
|
||||||
if ($lookupname eq '-' or $lookupname eq '0')
|
if ($lookupname eq '-' or $lookupname eq '0')
|
||||||
{
|
{
|
||||||
warn sprintf
|
if (!$lookup_opt)
|
||||||
"invalid zero OID reference in %s.dat field %s line %s\n",
|
{
|
||||||
$catname, $attname, $bki_values->{line_number}
|
warn sprintf
|
||||||
if !$lookup_opt;
|
"invalid zero OID reference in %s.dat field %s line %s\n",
|
||||||
|
$catname, $attname, $bki_values->{line_number};
|
||||||
|
$num_errors++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
warn sprintf
|
warn sprintf
|
||||||
"unresolved OID reference \"%s\" in %s.dat field %s line %s\n",
|
"unresolved OID reference \"%s\" in %s.dat field %s line %s\n",
|
||||||
$lookupname, $catname, $attname, $bki_values->{line_number};
|
$lookupname, $catname, $attname, $bki_values->{line_number};
|
||||||
|
$num_errors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue