Clarify coding in Catalog::AddDefaultValues.
Make it a bit shorter and better-commented; no functional change.
Alvaro Herrera and Tom Lane
Discussion:
@@ -331,26 +331,23 @@ sub AddDefaultValues
foreach my $column (@$schema)
{
my $attname = $column->{name};
- my $atttype = $column->{type};
- if (defined $row->{$attname})
- {
- ;
- }
- elsif ($attname eq 'oid')
- {
- ;
- }
- elsif (defined $column->{default})
+ # No work if field already has a value.
+ next if defined $row->{$attname};
+
+ # Ignore 'oid' columns, they're handled elsewhere.
+ next if $attname eq 'oid';
+
+ # If column has a default value, fill that in.
+ if (defined $column->{default})
{
$row->{$attname} = $column->{default};
+ next;
}
- else
- {
- # Failed to find a value.
+
+ # Failed to find a value for this field.
push @missing_fields, $attname;
}
- }
# Failure to provide all columns is a hard error.
if (@missing_fields)
