mirror of
https://github.com/postgres/postgres.git
synced 2025-05-08 07:21:33 +03:00
Clarify coding in Catalog::AddDefaultValues.
Make it a bit shorter and better-commented; no functional change. Alvaro Herrera and Tom Lane Discussion: https://postgr.es/m/20200212182337.GZ1412@telsasoft.com
This commit is contained in:
parent
b78542b9e9
commit
9d1ec5a8e1
@ -331,26 +331,23 @@ sub AddDefaultValues
|
|||||||
foreach my $column (@$schema)
|
foreach my $column (@$schema)
|
||||||
{
|
{
|
||||||
my $attname = $column->{name};
|
my $attname = $column->{name};
|
||||||
my $atttype = $column->{type};
|
|
||||||
|
|
||||||
if (defined $row->{$attname})
|
# No work if field already has a value.
|
||||||
{
|
next if defined $row->{$attname};
|
||||||
;
|
|
||||||
}
|
# Ignore 'oid' columns, they're handled elsewhere.
|
||||||
elsif ($attname eq 'oid')
|
next if $attname eq 'oid';
|
||||||
{
|
|
||||||
;
|
# If column has a default value, fill that in.
|
||||||
}
|
if (defined $column->{default})
|
||||||
elsif (defined $column->{default})
|
|
||||||
{
|
{
|
||||||
$row->{$attname} = $column->{default};
|
$row->{$attname} = $column->{default};
|
||||||
|
next;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
# Failed to find a value for this field.
|
||||||
# Failed to find a value.
|
|
||||||
push @missing_fields, $attname;
|
push @missing_fields, $attname;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Failure to provide all columns is a hard error.
|
# Failure to provide all columns is a hard error.
|
||||||
if (@missing_fields)
|
if (@missing_fields)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user