Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d1ec5a

Browse filesBrowse 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
Copy full SHA for 9d1ec5a

File tree

Expand file treeCollapse file tree

1 file changed

+12
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-15
lines changed

‎src/backend/catalog/Catalog.pm

Copy file name to clipboardExpand all lines: src/backend/catalog/Catalog.pm
+12-15Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.