Re: assert pg_class.relnatts is consistent
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Amit Langote <amitlangote09@gmail.com>
Cc: John Naylor <john.naylor@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, Justin Pryzby <pryzby@telsasoft.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-02-14T15:13:01Z
Lists: pgsql-hackers
I propose this more concise coding for AddDefaultValues,
# Now fill in defaults, and note any columns that remain undefined.
foreach my $column (@$schema)
{
my $attname = $column->{name};
my $atttype = $column->{type};
# Skip if a value already exists
next if defined $row->{$attname};
# 'oid' and 'relnatts' are special cases. Ignore.
next if $attname eq 'oid';
next if $attname eq 'relnatts';
# This column has a default value. Fill it in.
if (defined $column->{default})
{
$row->{$attname} = $column->{default};
next;
}
# Failed to find a value.
push @missing_fields, $attname;
}
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Update obsolete comment.
- faade5d4c6d8 13.0 landed
-
Clarify coding in Catalog::AddDefaultValues.
- 9d1ec5a8e155 13.0 landed
-
Run "make reformat-dat-files".
- b78542b9e975 13.0 landed
-
Don't require pg_class.dat to contain correct relnatts values.
- 86ff085e8388 13.0 landed