| From: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> | 
|---|---|
| To: | Marko Elezovic <marko(dot)elezovic(at)oradian(dot)com> | 
| Cc: | "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> | 
| Subject: | Re: Commenting a FK crashes ALTER TABLE statements | 
| Date: | 2017-05-15 04:05:07 | 
| Message-ID: | CAKJS1f9HdROUL+2OsSSeLfEgkFuxUnuySP_s0mLpHcVjjLESzQ@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-bugs | 
On 15 May 2017 at 03:43, Marko Elezovic <marko(dot)elezovic(at)oradian(dot)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
| Attachment | Content-Type | Size | 
|---|---|---|
| recomment_fix.patch | application/octet-stream | 709 bytes | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2017-05-15 04:19:57 | Re: Commenting a FK crashes ALTER TABLE statements | 
| Previous Message | Noah Misch | 2017-05-15 03:50:36 | Re: Concurrent ALTER SEQUENCE RESTART Regression |