aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-04-25 14:00:19 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-04-25 14:00:19 -0400
commitf04d4ac919b9ae9b57e977523e4b40979aa8b951 (patch)
treeea104f87f210c15479c92bc5f4dd8c06f7a30583 /src/backend
parent46cda5bf7bc209554b3c1bbb3040b45735387e0c (diff)
downloadpostgresql-f04d4ac919b9ae9b57e977523e4b40979aa8b951.tar.gz
postgresql-f04d4ac919b9ae9b57e977523e4b40979aa8b951.zip
Reindent Perl files with perltidy version 20170521.
Discussion: https://postgr.es/m/CABUevEzK3cNiHZQ18f5tK0guoT+cN_jWeVzhYYxY=r+1Q3SmoA@mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/catalog/Catalog.pm298
-rw-r--r--src/backend/catalog/genbki.pl83
-rw-r--r--src/backend/utils/Gen_fmgrtab.pl14
3 files changed, 202 insertions, 193 deletions
diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index 6305a2b3629..ce425562f51 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -33,185 +33,186 @@ sub ParseHeader
'TransactionId' => 'xid',
'XLogRecPtr' => 'pg_lsn');
- my %catalog;
- my $declaring_attributes = 0;
- my $is_varlen = 0;
- my $is_client_code = 0;
+ my %catalog;
+ my $declaring_attributes = 0;
+ my $is_varlen = 0;
+ my $is_client_code = 0;
- $catalog{columns} = [];
- $catalog{toasting} = [];
- $catalog{indexing} = [];
- $catalog{client_code} = [];
+ $catalog{columns} = [];
+ $catalog{toasting} = [];
+ $catalog{indexing} = [];
+ $catalog{client_code} = [];
- open(my $ifh, '<', $input_file) || die "$input_file: $!";
+ open(my $ifh, '<', $input_file) || die "$input_file: $!";
- # Scan the input file.
- while (<$ifh>)
- {
+ # Scan the input file.
+ while (<$ifh>)
+ {
- # Set appropriate flag when we're in certain code sections.
- if (/^#/)
+ # Set appropriate flag when we're in certain code sections.
+ if (/^#/)
+ {
+ $is_varlen = 1 if /^#ifdef\s+CATALOG_VARLEN/;
+ if (/^#ifdef\s+EXPOSE_TO_CLIENT_CODE/)
{
- $is_varlen = 1 if /^#ifdef\s+CATALOG_VARLEN/;
- if (/^#ifdef\s+EXPOSE_TO_CLIENT_CODE/)
- {
- $is_client_code = 1;
- next;
- }
- next if !$is_client_code;
+ $is_client_code = 1;
+ next;
}
+ next if !$is_client_code;
+ }
- if (!$is_client_code)
+ if (!$is_client_code)
+ {
+ # Strip C-style comments.
+ s;/\*(.|\n)*\*/;;g;
+ if (m;/\*;)
{
- # Strip C-style comments.
- s;/\*(.|\n)*\*/;;g;
- if (m;/\*;)
- {
-
- # handle multi-line comments properly.
- my $next_line = <$ifh>;
- die "$input_file: ends within C-style comment\n"
- if !defined $next_line;
- $_ .= $next_line;
- redo;
- }
- # Strip useless whitespace and trailing semicolons.
- chomp;
- s/^\s+//;
- s/;\s*$//;
- s/\s+/ /g;
+ # handle multi-line comments properly.
+ my $next_line = <$ifh>;
+ die "$input_file: ends within C-style comment\n"
+ if !defined $next_line;
+ $_ .= $next_line;
+ redo;
}
- # Push the data into the appropriate data structure.
- if (/^DECLARE_TOAST\(\s*(\w+),\s*(\d+),\s*(\d+)\)/)
+ # Strip useless whitespace and trailing semicolons.
+ chomp;
+ s/^\s+//;
+ s/;\s*$//;
+ s/\s+/ /g;
+ }
+
+ # Push the data into the appropriate data structure.
+ if (/^DECLARE_TOAST\(\s*(\w+),\s*(\d+),\s*(\d+)\)/)
+ {
+ my ($toast_name, $toast_oid, $index_oid) = ($1, $2, $3);
+ push @{ $catalog{toasting} },
+ "declare toast $toast_oid $index_oid on $toast_name\n";
+ }
+ elsif (/^DECLARE_(UNIQUE_)?INDEX\(\s*(\w+),\s*(\d+),\s*(.+)\)/)
+ {
+ my ($is_unique, $index_name, $index_oid, $using) =
+ ($1, $2, $3, $4);
+ push @{ $catalog{indexing} },
+ sprintf(
+ "declare %sindex %s %s %s\n",
+ $is_unique ? 'unique ' : '',
+ $index_name, $index_oid, $using);
+ }
+ elsif (/^BUILD_INDICES/)
+ {
+ push @{ $catalog{indexing} }, "build indices\n";
+ }
+ elsif (/^CATALOG\((\w+),(\d+),(\w+)\)/)
+ {
+ $catalog{catname} = $1;
+ $catalog{relation_oid} = $2;
+ $catalog{relation_oid_macro} = $3;
+
+ $catalog{bootstrap} = /BKI_BOOTSTRAP/ ? ' bootstrap' : '';
+ $catalog{shared_relation} =
+ /BKI_SHARED_RELATION/ ? ' shared_relation' : '';
+ $catalog{without_oids} =
+ /BKI_WITHOUT_OIDS/ ? ' without_oids' : '';
+ if (/BKI_ROWTYPE_OID\((\d+),(\w+)\)/)
{
- my ($toast_name, $toast_oid, $index_oid) = ($1, $2, $3);
- push @{ $catalog{toasting} },
- "declare toast $toast_oid $index_oid on $toast_name\n";
+ $catalog{rowtype_oid} = $1;
+ $catalog{rowtype_oid_clause} = " rowtype_oid $1";
+ $catalog{rowtype_oid_macro} = $2;
}
- elsif (/^DECLARE_(UNIQUE_)?INDEX\(\s*(\w+),\s*(\d+),\s*(.+)\)/)
+ else
{
- my ($is_unique, $index_name, $index_oid, $using) =
- ($1, $2, $3, $4);
- push @{ $catalog{indexing} },
- sprintf(
- "declare %sindex %s %s %s\n",
- $is_unique ? 'unique ' : '',
- $index_name, $index_oid, $using);
+ $catalog{rowtype_oid} = '';
+ $catalog{rowtype_oid_clause} = '';
+ $catalog{rowtype_oid_macro} = '';
}
- elsif (/^BUILD_INDICES/)
+ $catalog{schema_macro} = /BKI_SCHEMA_MACRO/ ? 1 : 0;
+ $declaring_attributes = 1;
+ }
+ elsif ($is_client_code)
+ {
+ if (/^#endif/)
{
- push @{ $catalog{indexing} }, "build indices\n";
+ $is_client_code = 0;
}
- elsif (/^CATALOG\((\w+),(\d+),(\w+)\)/)
+ else
{
- $catalog{catname} = $1;
- $catalog{relation_oid} = $2;
- $catalog{relation_oid_macro} = $3;
-
- $catalog{bootstrap} = /BKI_BOOTSTRAP/ ? ' bootstrap' : '';
- $catalog{shared_relation} =
- /BKI_SHARED_RELATION/ ? ' shared_relation' : '';
- $catalog{without_oids} =
- /BKI_WITHOUT_OIDS/ ? ' without_oids' : '';
- if (/BKI_ROWTYPE_OID\((\d+),(\w+)\)/)
- {
- $catalog{rowtype_oid} = $1;
- $catalog{rowtype_oid_clause} = " rowtype_oid $1";
- $catalog{rowtype_oid_macro} = $2;
- }
- else
- {
- $catalog{rowtype_oid} = '';
- $catalog{rowtype_oid_clause} = '';
- $catalog{rowtype_oid_macro} = '';
- }
- $catalog{schema_macro} = /BKI_SCHEMA_MACRO/ ? 1 : 0;
- $declaring_attributes = 1;
+ push @{ $catalog{client_code} }, $_;
}
- elsif ($is_client_code)
+ }
+ elsif ($declaring_attributes)
+ {
+ next if (/^{|^$/);
+ if (/^}/)
{
- if (/^#endif/)
- {
- $is_client_code = 0;
- }
- else
- {
- push @{ $catalog{client_code} }, $_;
- }
+ $declaring_attributes = 0;
}
- elsif ($declaring_attributes)
+ else
{
- next if (/^{|^$/);
- if (/^}/)
+ my %column;
+ my @attopts = split /\s+/, $_;
+ my $atttype = shift @attopts;
+ my $attname = shift @attopts;
+ die "parse error ($input_file)"
+ unless ($attname and $atttype);
+
+ if (exists $RENAME_ATTTYPE{$atttype})
{
- $declaring_attributes = 0;
+ $atttype = $RENAME_ATTTYPE{$atttype};
}
- else
+
+ # If the C name ends with '[]' or '[digits]', we have
+ # an array type, so we discard that from the name and
+ # prepend '_' to the type.
+ if ($attname =~ /(\w+)\[\d*\]/)
{
- my %column;
- my @attopts = split /\s+/, $_;
- my $atttype = shift @attopts;
- my $attname = shift @attopts;
- die "parse error ($input_file)"
- unless ($attname and $atttype);
-
- if (exists $RENAME_ATTTYPE{$atttype})
+ $attname = $1;
+ $atttype = '_' . $atttype;
+ }
+
+ $column{type} = $atttype;
+ $column{name} = $attname;
+ $column{is_varlen} = 1 if $is_varlen;
+
+ foreach my $attopt (@attopts)
+ {
+ if ($attopt eq 'BKI_FORCE_NULL')
{
- $atttype = $RENAME_ATTTYPE{$atttype};
+ $column{forcenull} = 1;
}
-
- # If the C name ends with '[]' or '[digits]', we have
- # an array type, so we discard that from the name and
- # prepend '_' to the type.
- if ($attname =~ /(\w+)\[\d*\]/)
+ elsif ($attopt eq 'BKI_FORCE_NOT_NULL')
{
- $attname = $1;
- $atttype = '_' . $atttype;
+ $column{forcenotnull} = 1;
}
- $column{type} = $atttype;
- $column{name} = $attname;
- $column{is_varlen} = 1 if $is_varlen;
+ # We use quotes for values like \0 and \054, to
+ # make sure all compilers and syntax highlighters
+ # can recognize them properly.
+ elsif ($attopt =~ /BKI_DEFAULT\(['"]?([^'"]+)['"]?\)/)
+ {
+ $column{default} = $1;
+ }
+ elsif ($attopt =~ /BKI_LOOKUP\((\w+)\)/)
+ {
+ $column{lookup} = $1;
+ }
+ else
+ {
+ die
+ "unknown column option $attopt on column $attname";
+ }
- foreach my $attopt (@attopts)
+ if ($column{forcenull} and $column{forcenotnull})
{
- if ($attopt eq 'BKI_FORCE_NULL')
- {
- $column{forcenull} = 1;
- }
- elsif ($attopt eq 'BKI_FORCE_NOT_NULL')
- {
- $column{forcenotnull} = 1;
- }
- # We use quotes for values like \0 and \054, to
- # make sure all compilers and syntax highlighters
- # can recognize them properly.
- elsif ($attopt =~ /BKI_DEFAULT\(['"]?([^'"]+)['"]?\)/)
- {
- $column{default} = $1;
- }
- elsif ($attopt =~ /BKI_LOOKUP\((\w+)\)/)
- {
- $column{lookup} = $1;
- }
- else
- {
- die
-"unknown column option $attopt on column $attname";
- }
-
- if ($column{forcenull} and $column{forcenotnull})
- {
- die "$attname is forced both null and not null";
- }
+ die "$attname is forced both null and not null";
}
- push @{ $catalog{columns} }, \%column;
}
+ push @{ $catalog{columns} }, \%column;
}
}
- close $ifh;
+ }
+ close $ifh;
return \%catalog;
}
@@ -228,7 +229,7 @@ sub ParseData
$input_file =~ /(\w+)\.dat$/
or die "Input file $input_file needs to be a .dat file.\n";
my $catname = $1;
- my $data = [];
+ my $data = [];
# Scan the input file.
while (<$ifd>)
@@ -311,8 +312,9 @@ sub AddDefaultValues
{
$row->{$attname} = $column->{default};
}
- elsif ($catname eq 'pg_proc' && $attname eq 'pronargs' &&
- defined($row->{proargtypes}))
+ elsif ($catname eq 'pg_proc'
+ && $attname eq 'pronargs'
+ && defined($row->{proargtypes}))
{
# pg_proc.pronargs can be derived from proargtypes.
my @proargtypes = split /\s+/, $row->{proargtypes};
@@ -328,7 +330,7 @@ sub AddDefaultValues
if (@missing_fields)
{
die sprintf "missing values for field(s) %s in %s.dat line %s\n",
- join(', ', @missing_fields), $catname, $row->{line_number};
+ join(', ', @missing_fields), $catname, $row->{line_number};
}
}
@@ -379,7 +381,7 @@ sub FindDefinedSymbol
sub FindDefinedSymbolFromData
{
my ($data, $symbol) = @_;
- foreach my $row (@{ $data })
+ foreach my $row (@{$data})
{
if ($row->{oid_symbol} eq $symbol)
{
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 9cf26263f8f..5d4fa5c1544 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -116,10 +116,12 @@ foreach my $header (@input_files)
# within a given Postgres release, such as fixed OIDs. Do not substitute
# anything that could depend on platform or configuration. (The right place
# to handle those sorts of things is in initdb.c's bootstrap_template1().)
-my $BOOTSTRAP_SUPERUSERID = Catalog::FindDefinedSymbolFromData(
- $catalog_data{pg_authid}, 'BOOTSTRAP_SUPERUSERID');
-my $PG_CATALOG_NAMESPACE = Catalog::FindDefinedSymbolFromData(
- $catalog_data{pg_namespace}, 'PG_CATALOG_NAMESPACE');
+my $BOOTSTRAP_SUPERUSERID =
+ Catalog::FindDefinedSymbolFromData($catalog_data{pg_authid},
+ 'BOOTSTRAP_SUPERUSERID');
+my $PG_CATALOG_NAMESPACE =
+ Catalog::FindDefinedSymbolFromData($catalog_data{pg_namespace},
+ 'PG_CATALOG_NAMESPACE');
# Build lookup tables for OID macro substitutions and for pg_attribute
@@ -138,8 +140,7 @@ foreach my $row (@{ $catalog_data{pg_opclass} })
{
# There is no unique name, so we need to combine access method
# and opclass name.
- my $key = sprintf "%s/%s",
- $row->{opcmethod}, $row->{opcname};
+ my $key = sprintf "%s/%s", $row->{opcmethod}, $row->{opcname};
$opcoids{$key} = $row->{oid};
}
@@ -160,8 +161,7 @@ foreach my $row (@{ $catalog_data{pg_opfamily} })
{
# There is no unique name, so we need to combine access method
# and opfamily name.
- my $key = sprintf "%s/%s",
- $row->{opfmethod}, $row->{opfname};
+ my $key = sprintf "%s/%s", $row->{opfmethod}, $row->{opfname};
$opfoids{$key} = $row->{oid};
}
@@ -179,6 +179,7 @@ foreach my $row (@{ $catalog_data{pg_proc} })
{
$procoids{$prokey} = $row->{oid};
}
+
# Also generate an entry using proname(proargtypes). This is not quite
# identical to regprocedure lookup because we don't worry much about
# special SQL names for types etc; we just use the names in the source
@@ -201,7 +202,7 @@ my %types;
foreach my $row (@{ $catalog_data{pg_type} })
{
$typeoids{ $row->{typname} } = $row->{oid};
- $types{ $row->{typname} } = $row;
+ $types{ $row->{typname} } = $row;
}
# Map catalog name to OID lookup.
@@ -211,8 +212,7 @@ my %lookup_kind = (
pg_operator => \%operoids,
pg_opfamily => \%opfoids,
pg_proc => \%procoids,
- pg_type => \%typeoids
-);
+ pg_type => \%typeoids);
# Generate postgres.bki, postgres.description, postgres.shdescription,
@@ -345,11 +345,14 @@ EOM
# Complain about unrecognized keys; they are presumably misspelled
foreach my $key (keys %bki_values)
{
- next if $key eq "oid" || $key eq "oid_symbol" || $key eq "descr"
- || $key eq "line_number";
+ next
+ if $key eq "oid"
+ || $key eq "oid_symbol"
+ || $key eq "descr"
+ || $key eq "line_number";
die sprintf "unrecognized field name \"%s\" in %s.dat line %s\n",
- $key, $catname, $bki_values{line_number}
- if (!exists($attnames{$key}));
+ $key, $catname, $bki_values{line_number}
+ if (!exists($attnames{$key}));
}
# Perform required substitutions on fields
@@ -379,8 +382,8 @@ EOM
if ($atttype eq 'oidvector')
{
@lookupnames = split /\s+/, $bki_values{$attname};
- @lookupoids = lookup_oids($lookup, $catname,
- \%bki_values, @lookupnames);
+ @lookupoids = lookup_oids($lookup, $catname, \%bki_values,
+ @lookupnames);
$bki_values{$attname} = join(' ', @lookupoids);
}
elsif ($atttype eq '_oid')
@@ -389,17 +392,18 @@ EOM
{
$bki_values{$attname} =~ s/[{}]//g;
@lookupnames = split /,/, $bki_values{$attname};
- @lookupoids = lookup_oids($lookup, $catname,
- \%bki_values, @lookupnames);
- $bki_values{$attname} =
- sprintf "{%s}", join(',', @lookupoids);
+ @lookupoids =
+ lookup_oids($lookup, $catname, \%bki_values,
+ @lookupnames);
+ $bki_values{$attname} = sprintf "{%s}",
+ join(',', @lookupoids);
}
}
else
{
$lookupnames[0] = $bki_values{$attname};
- @lookupoids = lookup_oids($lookup, $catname,
- \%bki_values, @lookupnames);
+ @lookupoids = lookup_oids($lookup, $catname, \%bki_values,
+ @lookupnames);
$bki_values{$attname} = $lookupoids[0];
}
}
@@ -562,7 +566,7 @@ sub gen_pg_attribute
morph_row_for_schemapg(\%row, $schema);
push @{ $schemapg_entries{$table_name} },
sprintf "{ %s }",
- join(', ', grep { defined $_ } @row{@attnames});
+ join(', ', grep { defined $_ } @row{@attnames});
}
# Generate entries for system attributes.
@@ -589,7 +593,7 @@ sub gen_pg_attribute
# Omit the oid column if the catalog doesn't have them
next
if $table->{without_oids}
- && $attr->{name} eq 'oid';
+ && $attr->{name} eq 'oid';
morph_row_for_pgattr(\%row, $schema, $attr, 1);
print_bki_insert(\%row, $schema);
@@ -641,11 +645,11 @@ sub morph_row_for_pgattr
# compare DefineAttr in bootstrap.c. oidvector and
# int2vector are also treated as not-nullable.
$row->{attnotnull} =
- $type->{typname} eq 'oidvector' ? 't'
- : $type->{typname} eq 'int2vector' ? 't'
- : $type->{typlen} eq 'NAMEDATALEN' ? 't'
- : $type->{typlen} > 0 ? 't'
- : 'f';
+ $type->{typname} eq 'oidvector' ? 't'
+ : $type->{typname} eq 'int2vector' ? 't'
+ : $type->{typlen} eq 'NAMEDATALEN' ? 't'
+ : $type->{typlen} > 0 ? 't'
+ : 'f';
}
else
{
@@ -686,7 +690,7 @@ sub print_bki_insert
# the "id" pattern in bootscanner.l, currently "[-A-Za-z0-9_]+".
$bki_value = sprintf(qq'"%s"', $bki_value)
if length($bki_value) == 0
- or $bki_value =~ /[^-A-Za-z0-9_]/;
+ or $bki_value =~ /[^-A-Za-z0-9_]/;
push @bki_values, $bki_value;
}
@@ -725,7 +729,7 @@ sub morph_row_for_schemapg
# don't change.
elsif ($atttype eq 'bool')
{
- $row->{$attname} = 'true' if $row->{$attname} eq 't';
+ $row->{$attname} = 'true' if $row->{$attname} eq 't';
$row->{$attname} = 'false' if $row->{$attname} eq 'f';
}
@@ -756,9 +760,10 @@ sub lookup_oids
else
{
push @lookupoids, $lookupname;
- warn sprintf "unresolved OID reference \"%s\" in %s.dat line %s\n",
- $lookupname, $catname, $bki_values->{line_number}
- if $lookupname ne '-' and $lookupname ne '0';
+ warn sprintf
+ "unresolved OID reference \"%s\" in %s.dat line %s\n",
+ $lookupname, $catname, $bki_values->{line_number}
+ if $lookupname ne '-' and $lookupname ne '0';
}
}
return @lookupoids;
@@ -772,10 +777,10 @@ sub form_pg_type_symbol
# Skip for rowtypes of bootstrap catalogs, since they have their
# own naming convention defined elsewhere.
return
- if $typename eq 'pg_type'
- or $typename eq 'pg_proc'
- or $typename eq 'pg_attribute'
- or $typename eq 'pg_class';
+ if $typename eq 'pg_type'
+ or $typename eq 'pg_proc'
+ or $typename eq 'pg_attribute'
+ or $typename eq 'pg_class';
# Transform like so:
# foo_bar -> FOO_BAROID
diff --git a/src/backend/utils/Gen_fmgrtab.pl b/src/backend/utils/Gen_fmgrtab.pl
index 4f5af79d0b5..3ba1611f18b 100644
--- a/src/backend/utils/Gen_fmgrtab.pl
+++ b/src/backend/utils/Gen_fmgrtab.pl
@@ -68,7 +68,7 @@ foreach my $datfile (@input_files)
my $header = "$1.h";
die "There in no header file corresponding to $datfile"
- if ! -e $header;
+ if !-e $header;
my $catalog = Catalog::ParseHeader($header);
my $catname = $catalog->{catname};
@@ -79,10 +79,12 @@ foreach my $datfile (@input_files)
}
# Fetch some values for later.
-my $FirstBootstrapObjectId = Catalog::FindDefinedSymbol(
- 'access/transam.h', \@include_path, 'FirstBootstrapObjectId');
-my $INTERNALlanguageId = Catalog::FindDefinedSymbolFromData(
- $catalog_data{pg_language}, 'INTERNALlanguageId');
+my $FirstBootstrapObjectId =
+ Catalog::FindDefinedSymbol('access/transam.h', \@include_path,
+ 'FirstBootstrapObjectId');
+my $INTERNALlanguageId =
+ Catalog::FindDefinedSymbolFromData($catalog_data{pg_language},
+ 'INTERNALlanguageId');
print "Generating fmgrtab.c, fmgroids.h, and fmgrprotos.h...\n";
@@ -230,7 +232,7 @@ foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
print $tfh
" { $s->{oid}, \"$s->{prosrc}\", $s->{nargs}, $bmap{$s->{strict}}, $bmap{$s->{retset}}, $s->{prosrc} }";
- $fmgr_builtin_oid_index[$s->{oid}] = $fmgr_count++;
+ $fmgr_builtin_oid_index[ $s->{oid} ] = $fmgr_count++;
if ($fmgr_count <= $#fmgr)
{