Re: assert pg_class.relnatts is consistent
Amit Langote <amitlangote09@gmail.com>
From: Amit Langote <amitlangote09@gmail.com>
To: John Naylor <john.naylor@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Justin Pryzby <pryzby@telsasoft.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-02-14T14:22:05Z
Lists: pgsql-hackers
Attachments
- v2-0001-Don-t-require-relnatts-to-be-specified-in-pg_clas.patch (application/octet-stream) patch v2-0001
Hi John,
On Fri, Feb 14, 2020 at 6:50 PM John Naylor <john.naylor@2ndquadrant.com> wrote:
> On Fri, Feb 14, 2020 at 5:00 PM Amit Langote <amitlangote09@gmail.com> wrote:
> > I tried and think it works but not sure if that's good Perl
> > programming. See the attached.
>
> Hi Amit,
> I took this for a spin -- I just have a couple comments.
Thanks for chiming in.
> + elsif ($attname eq 'relnatts')
> + {
> + ;
> + }
>
> With your patch, I get this when running
> src/include/catalog/reformat_dat_file.pl:
>
> strip_default_values: pg_class.relnatts undefined
I think I have fixed this in the attached.
> + if ($catname eq "pg_class" && $attname eq "relnatts")
> + {
> + $bki_values{$attname} = $catalog_ncols{$bki_values{relname}};
> + }
> +
>
> You could avoid the name/attr checks if you do it while building the
> pg_class lookup table, like this:
>
> foreach my $row (@{ $catalog_data{pg_class} })
> {
> $classoids{ $row->{relname} } = $row->{oid};
> +
> + # Also fill in correct value for relnatts.
> + $row->{relnatts} = $catalog_ncols{ $row->{relname} };
> }
Did this too. Attached updated patch, which also addresses Michael's comment.
I'm still trying to understand your comment about using placeholder
BKI_DEFAULT...
Thanks,
Amit
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