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

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY
Date: 2015-07-14 08:43:50
Message-ID: E1ZEvoc-0002RV-Vh@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

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(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-07-14 13:02:58 Re: pgsql: Retain comments on indexes and constraints at ALTER TABLE ... TY
Previous Message Bruce Momjian 2015-07-12 21:42:52 pgsql: release notes: markup: vacuumdb is an application, not command

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-07-14 08:45:35 Re: [BUGS] BUG #13126: table constraint loses its comment
Previous Message Alvaro Herrera 2015-07-14 07:44:04 Re: git push hook to check for outdated timestamps