pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY

Поиск
Список
Период
Сортировка
Искать

pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY

От:
Heikki Linnakangas <heikki.linnakangas@iki.fi>
Дата:
Retain comments on indexes and constraints at ALTER TABLE ... TYPE ...

When a column's datatype is changed, ATExecAlterColumnType() rebuilds all
the affected indexes and constraints, and the comments from the old
indexes/constraints were not carried over.

To fix, create a synthetic COMMENT ON command in the work queue, to re-add
any comments on constraints. For indexes, there's a comment field in
IndexStmt that is used.

This fixes bug #13126, reported by Kirill Simonov. Original patch by
Michael Paquier, reviewed by Petr Jelinek and me. This bug is present in
all versions, but only backpatch to 9.5. Given how minor the issue is, it
doesn't seem worth the work and risk to backpatch further than that.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e42375fc8124e99c33fa330c53c2b4b502fa0baf

Modified Files
--------------
src/backend/commands/tablecmds.c          |   65 ++++++++++++++++++++++++++++-
src/include/nodes/parsenodes.h            |    1 +
src/test/regress/expected/alter_table.out |   63 ++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      |   36 ++++++++++++++++
4 files changed, 163 insertions(+), 2 deletions(-)

Re: pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Heikki Linnakangas  writes:
> Retain comments on indexes and constraints at ALTER TABLE ... TYPE ...

One or the other of these patches has broken the majority of the
buildfarm.

			regards, tom lane

Re: pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY

От:
Michael Paquier <michael.paquier@gmail.com>
Дата:
Вложения:
On Tue, Jul 14, 2015 at 10:02 PM, Tom Lane  wrote:
> Heikki Linnakangas  writes:
>> Retain comments on indexes and constraints at ALTER TABLE ... TYPE ...
>
> One or the other of these patches has broken the majority of the
> buildfarm.

Some ORDER BY clauses are missing to make the output consistent it
seems. At the same time the queries could be reformated a bit to not
be longer than 80 characters. A patch is attached.
-- 
Michael

Re: pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY

От:
Heikki Linnakangas <hlinnaka@iki.fi>
Дата:
On 07/14/2015 04:02 PM, Tom Lane wrote:
> Heikki Linnakangas  writes:
>> Retain comments on indexes and constraints at ALTER TABLE ... TYPE ...
>
> One or the other of these patches has broken the majority of the
> buildfarm.

Ah, the order of the rows in the test queries was not stable. Added 
ORDER BYs. Sorry about that.

- Heikki

Re: pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY

От:
Kevin Grittner <kgrittn@ymail.com>
Дата:
Heikki Linnakangas  wrote:

> This fixes bug #13126, reported by Kirill Simonov.

It looks like you missed something with the addition of
AT_ReAddComment:

test_ddl_deparse.c:80:11: warning: enumeration value 'AT_ReAddComment' not handled in switch [-Wswitch]
                switch (subcmd->subtype)
                        ^

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY

От:
Michael Paquier <michael.paquier@gmail.com>
Дата:
Вложения:
On Fri, Jul 17, 2015 at 11:16 PM, Kevin Grittner  wrote:
> Heikki Linnakangas  wrote:
>
>> This fixes bug #13126, reported by Kirill Simonov.
>
> It looks like you missed something with the addition of
> AT_ReAddComment:
>
> test_ddl_deparse.c:80:11: warning: enumeration value 'AT_ReAddComment' not handled in switch [-Wswitch]
>                 switch (subcmd->subtype)
>                         ^

Oops. If someone could pick up the attached (backpatch to 9.5 needed)...
-- 
Michael
FAQ