Re: BUG #13126: table constraint loses its comment

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: BUG #13126: table constraint loses its comment
Дата
Msg-id CAB7nPqRk+Y_agaYWtjyQtghGL_m8_PSER=d85E2yvhtY3sh0ug@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #13126: table constraint loses its comment  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: BUG #13126: table constraint loses its comment  (Heikki Linnakangas <hlinnaka@iki.fi>)
Re: BUG #13126: table constraint loses its comment  (Petr Jelinek <petr@2ndquadrant.com>)
Список pgsql-bugs
On Wed, Apr 29, 2015 at 1:30 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:
> On Sun, Apr 26, 2015 at 6:05 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> xi@resolvent.net writes:
>>> In some circumstances, the comment on a table constraint disappears.  Here
>>> is an example:
>>
>> Hm, yeah.  The problem is that ATExecAlterColumnType() rebuilds all the
>> affected indexes from scratch, and it isn't doing anything about copying
>> their comments to the new objects (either comments on the constraints, or
>> comments directly on the indexes).
>>
>> The least painful way to fix it might be to charter ATPostAlterTypeCleanup
>> to create COMMENT commands and add those to the appropriate work queue,
>> rather than complicating the data structure initially emitted by
>> ATExecAlterColumnType.  But it'd still be a fair amount of new code I'm
>> afraid.
>>
>> Not planning to fix this personally, but maybe someone else would like to
>> take it up.
>
> In order to fix this, an idea would be to add a new routine in
> ruleutils.c that generates the COMMENT query string, and then call it
> directly from tablecmds.c. On master, I imagine that we could even add
> some SQL interface if there is some need.
> Thoughts?

After looking at this problem, I noticed that the test case given
above does not cover everything: primary key indexes, constraints
(CHECK for example) and indexes alone have also their comments removed
after ALTER TABLE when those objects are re-created. I finished with
the patch attached to fix everything, patch that includes a set of
regression tests covering all the code paths added.
--
Michael

Вложения

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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: Incorrect processing of CREATE TRANSFORM with DDL deparding
Следующее
От: lincpa@163.com
Дата:
Сообщение: BUG #13360: initdb --locale = C error