Re: pgsql: Fix table rewrites that include a column without adefault.

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: pgsql: Fix table rewrites that include a column without adefault.
Дата
Msg-id 20191016055817.GE2602@paquier.xyz
обсуждение исходный текст
Ответ на Re: pgsql: Fix table rewrites that include a column without a default.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-committers
On Thu, Oct 10, 2019 at 05:16:08PM -0400, Tom Lane wrote:
> I really really don't want an event trigger running in everything that
> runs in parallel with alter_table.  That's a debugging nightmare of
> monster proportions.

+1, that's not stable.  elver has just complained about a side effect
of this commit:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=elver&dt=2019-10-16%2005%3A04%3A24
 -- now change 'name' to an integer to see what happens...
 ALTER TABLE alter_table_under_transition_tables
 ALTER COLUMN name TYPE int USING name::integer;
+WARNING:  rewriting table alter_table_under_transition_tables
 UPDATE alter_table_under_transition_tables
 SET name = (name::text || name::text)::integer;
 WARNING:  old table = 1=11,2=22,3=33, new table = 1=1111,2=2222,3=3333

Another method would be to simply store the past relfilenodes into a
temporary table with the relation OID, and do a comparison with what's
in pg_class post-rewrite as some partition-related tests do in the
same file.  For one relation the \gset method is more readable
anyway.

If you really wish to keep an event trigger, you could also apply a
filter within the function to only consider rewrite_test as something
to report about, still I would recommend avoiding global effects if
not necessary.

So I would fix the issue as per the attached, as Tom has suggested.
Thoughts?
--
Michael

Вложения

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

Предыдущее
От: Thomas Munro
Дата:
Сообщение: pgsql: Remove obsolete collation test.
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Refresh some incorrect links in pg_crc.c/h