Skip to content

Commit 9d1ec5a

Browse files
committed
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
1 parent b78542b commit 9d1ec5a

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/backend/catalog/Catalog.pm

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -331,25 +331,22 @@ sub AddDefaultValues
331331
foreach my $column (@$schema)
332332
{
333333
my $attname = $column->{name};
334-
my $atttype = $column->{type};
335334

336-
if (defined $row->{$attname})
337-
{
338-
;
339-
}
340-
elsif ($attname eq 'oid')
341-
{
342-
;
343-
}
344-
elsif (defined $column->{default})
335+
# No work if field already has a value.
336+
next if defined $row->{$attname};
337+
338+
# Ignore 'oid' columns, they're handled elsewhere.
339+
next if $attname eq 'oid';
340+
341+
# If column has a default value, fill that in.
342+
if (defined $column->{default})
345343
{
346344
$row->{$attname} = $column->{default};
345+
next;
347346
}
348-
else
349-
{
350-
# Failed to find a value.
351-
push @missing_fields, $attname;
352-
}
347+
348+
# Failed to find a value for this field.
349+
push @missing_fields, $attname;
353350
}
354351

355352
# Failure to provide all columns is a hard error.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy