summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Naylor2022-09-08 06:54:14 +0000
committerJohn Naylor2022-09-08 07:01:13 +0000
commitb2e6e768230be334b12dae536ba4c147fba4e9c9 (patch)
treef32437b9fc664f9a7e1240b24e56f770eda1b25b /src
parent69eb643b2582f180c91b2d14c896402e54040231 (diff)
Run perltidy over Catalog.pm
Commit 69eb643b2 deliberately left indentation unchanged to make the changes more legible. Rather than waiting until next year's perltidy run, do it now to avoid confusion Per suggestion from Álvaro Herrera Discussion: https://www.postgresql.org/message-id/20220907083558.vfvb5hcauaictgum%40alvherre.pgsql
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/Catalog.pm111
1 files changed, 56 insertions, 55 deletions
diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index 7c869bad72e..4a9fa3b2cbd 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -289,71 +289,72 @@ sub ParseData
if ($preserve_formatting)
{
- # Scan the input file.
- while (<$ifd>)
- {
- my $hash_ref;
-
- if (/{/)
+ # Scan the input file.
+ while (<$ifd>)
{
- # Capture the hash ref
- # NB: Assumes that the next hash ref can't start on the
- # same line where the present one ended.
- # Not foolproof, but we shouldn't need a full parser,
- # since we expect relatively well-behaved input.
-
- # Quick hack to detect when we have a full hash ref to
- # parse. We can't just use a regex because of values in
- # pg_aggregate and pg_proc like '{0,0}'. This will need
- # work if we ever need to allow unbalanced braces within
- # a field value.
- my $lcnt = tr/{//;
- my $rcnt = tr/}//;
-
- if ($lcnt == $rcnt)
+ my $hash_ref;
+
+ if (/{/)
{
- # We're treating the input line as a piece of Perl, so we
- # need to use string eval here. Tell perlcritic we know what
- # we're doing.
- eval '$hash_ref = ' . $_; ## no critic (ProhibitStringyEval)
- if (!ref $hash_ref)
+ # Capture the hash ref
+ # NB: Assumes that the next hash ref can't start on the
+ # same line where the present one ended.
+ # Not foolproof, but we shouldn't need a full parser,
+ # since we expect relatively well-behaved input.
+
+ # Quick hack to detect when we have a full hash ref to
+ # parse. We can't just use a regex because of values in
+ # pg_aggregate and pg_proc like '{0,0}'. This will need
+ # work if we ever need to allow unbalanced braces within
+ # a field value.
+ my $lcnt = tr/{//;
+ my $rcnt = tr/}//;
+
+ if ($lcnt == $rcnt)
{
- die "$input_file: error parsing line $.:\n$_\n";
- }
+ # We're treating the input line as a piece of Perl, so we
+ # need to use string eval here. Tell perlcritic we know what
+ # we're doing.
+ eval '$hash_ref = '
+ . $_; ## no critic (ProhibitStringyEval)
+ if (!ref $hash_ref)
+ {
+ die "$input_file: error parsing line $.:\n$_\n";
+ }
+
+ # Annotate each hash with the source line number.
+ $hash_ref->{line_number} = $.;
- # Annotate each hash with the source line number.
- $hash_ref->{line_number} = $.;
+ # Expand tuples to their full representation.
+ AddDefaultValues($hash_ref, $schema, $catname);
+ }
+ else
+ {
+ my $next_line = <$ifd>;
+ die "$input_file: file ends within Perl hash\n"
+ if !defined $next_line;
+ $_ .= $next_line;
+ redo;
+ }
+ }
- # Expand tuples to their full representation.
- AddDefaultValues($hash_ref, $schema, $catname);
+ # If we found a hash reference, keep it, unless it is marked as
+ # autogenerated; in that case it'd duplicate an entry we'll
+ # autogenerate below. (This makes it safe for reformat_dat_file.pl
+ # with --full-tuples to print autogenerated entries, which seems like
+ # useful behavior for debugging.)
+ #
+ # Otherwise, we have a non-data string, which we need to keep in
+ # order to preserve formatting.
+ if (defined $hash_ref)
+ {
+ push @$data, $hash_ref if !$hash_ref->{autogenerated};
}
else
{
- my $next_line = <$ifd>;
- die "$input_file: file ends within Perl hash\n"
- if !defined $next_line;
- $_ .= $next_line;
- redo;
+ push @$data, $_;
}
}
-
- # If we found a hash reference, keep it, unless it is marked as
- # autogenerated; in that case it'd duplicate an entry we'll
- # autogenerate below. (This makes it safe for reformat_dat_file.pl
- # with --full-tuples to print autogenerated entries, which seems like
- # useful behavior for debugging.)
- #
- # Otherwise, we have a non-data string, which we need to keep in
- # order to preserve formatting.
- if (defined $hash_ref)
- {
- push @$data, $hash_ref if !$hash_ref->{autogenerated};
- }
- else
- {
- push @$data, $_;
- }
- }
}
else
{