Re: [BUGS] Commenting a FK crashes ALTER TABLE statements - Mailing list pgsql-bugs

From David Rowley
Subject Re: [BUGS] Commenting a FK crashes ALTER TABLE statements
Date
Msg-id CAKJS1f9HdROUL+2OsSSeLfEgkFuxUnuySP_s0mLpHcVjjLESzQ@mail.gmail.com
Whole thread Raw
In response to [BUGS] Commenting a FK crashes ALTER TABLE statements  (Marko Elezovic <marko.elezovic@oradian.com>)
Responses Re: [BUGS] Commenting a FK crashes ALTER TABLE statements  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-bugs
On 15 May 2017 at 03:43, Marko Elezovic <marko.elezovic@oradian.com> wrote:
> Script to reproduce:
>
>   psql -Upostgres -c"DROP DATABASE IF EXISTS cod;" postgres
>
>   psql -Upostgres -c"CREATE DATABASE cod;" postgres
>
>   psql -Upostgres -c"CREATE TABLE foo(id int PRIMARY KEY);" cod
>
>   psql -Upostgres -c"CREATE TABLE bar(id int CONSTRAINT baz REFERENCES
> foo);" cod
>
>   psql -Upostgres -c"COMMENT ON CONSTRAINT baz ON bar IS 'Fubar';" cod
>
>   psql -Upostgres -c"ALTER TABLE foo ALTER COLUMN id TYPE int;" cod

Thanks for detailing out the method to reproduce.

It can be simplified a bit to become:

CREATE TABLE foo(id int PRIMARY KEY);
CREATE TABLE bar(id int CONSTRAINT baz REFERENCES foo);
COMMENT ON CONSTRAINT baz ON bar IS 'Fubar';
\c
ALTER TABLE foo ALTER COLUMN id TYPE int;

It seems there's just some missing pstrdup() calls in
RebuildConstraintComment().

The attached should fix it.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachment

pgsql-bugs by date:

Previous
From: Noah Misch
Date:
Subject: Re: [BUGS] Concurrent ALTER SEQUENCE RESTART Regression
Next
From: Michael Paquier
Date:
Subject: Re: [BUGS] Commenting a FK crashes ALTER TABLE statements