diff --git a/src/include/catalog/reformat_dat_file.pl b/src/include/catalog/reformat_dat_file.pl index ca20fb86da..54ad1b72e5 100755 --- a/src/include/catalog/reformat_dat_file.pl +++ b/src/include/catalog/reformat_dat_file.pl @@ -26,8 +26,11 @@ use FindBin; use lib "$FindBin::RealBin/../../backend/catalog/"; use Catalog; -# Names of the metadata fields of a catalog entry. (line_number is also -# a metadata field, but we never write it out, so it's not listed here.) +# Names of the metadata fields of a catalog entry. +# Note: oid is a normal column from a storage perspective, but it's more +# important than the rest, so it's listed first among the metadata fields. +# Note: line_number is also a metadata field, but we never write it out, +# so it's not listed here. my @METADATA = ('oid', 'oid_symbol', 'array_type_oid', 'descr', 'autogenerated'); @@ -119,7 +122,12 @@ foreach my $catname (@catnames) foreach my $column (@$schema) { my $attname = $column->{name}; - push @attnames, $attname; + + # We may have ordinary columns at the storage level that we still + # want to format as a special value. Exclude these from the column + # list so they are not written twice. + push @attnames, $attname + if !(grep { $_ eq $attname } @METADATA; } # Overwrite .dat files in place, since they are under version control. @@ -192,8 +200,11 @@ sub strip_default_values foreach my $column (@$schema) { my $attname = $column->{name}; + + # It's okay if we have no oid value, since it will be assigned + # automatically before bootstrap. die "strip_default_values: $catname.$attname undefined\n" - if !defined $row->{$attname}; + if !defined $row->{$attname} and $attname ne 'oid'; if (defined $column->{default} and ($row->{$attname} eq $column->{default}))