Re: assert pg_class.relnatts is consistent

Поиск
Список
Период
Сортировка
От John Naylor
Тема Re: assert pg_class.relnatts is consistent
Дата
Msg-id CACPNZCudQwPgsVcA9Eg20A+YdLvgsP9deF1PB2yWH-X0n4vh6Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: assert pg_class.relnatts is consistent  (Amit Langote <amitlangote09@gmail.com>)
Ответы Re: assert pg_class.relnatts is consistent  (John Naylor <john.naylor@2ndquadrant.com>)
Re: assert pg_class.relnatts is consistent  (Amit Langote <amitlangote09@gmail.com>)
Список pgsql-hackers
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.

+ 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

Rather than adding this one-off case to AddDefaultValues and then
another special case to strip_default_values, maybe it would be better
to just add a placeholder BKI_DEFAULT(0) to pg_class.h, with a comment
that it's just a placeholder.


+ 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} };
 }

-- 
John Naylor                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: assert pg_class.relnatts is consistent
Следующее
От: Pengzhou Tang
Дата:
Сообщение: Re: Extracting only the columns needed for a query