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

  1. Update obsolete comment.

  2. Clarify coding in Catalog::AddDefaultValues.

  3. Run "make reformat-dat-files".

  4. Don't require pg_class.dat to contain correct relnatts values.