Re: Commenting a FK crashes ALTER TABLE statements

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Marko Elezovic <marko(dot)elezovic(at)oradian(dot)com>, "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:19:57
Message-ID: CAB7nPqSndh49vF=DSdm4vFent+3Qq0Suo-ND=g_ZeNCGDUZtGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, May 15, 2017 at 1:05 PM, David Rowley
<david(dot)rowley(at)2ndquadrant(dot)com> wrote:
> 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.

I was just finishing to debug it :)
It is surprising that we have not caught this earlier as comment
re-creation handling in ALTER TABLE has been reworked some time ago
already. This means that we did not stress this code enough. Attached
is the previous fix, completed with a set of regression tests.
--
Michael

Attachment Content-Type Size
recomment_fix_v2.patch application/octet-stream 5.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Sebastion Calbaza 2017-05-15 06:29:18 Re: BUG #14648: counts for queries using array unnesting is incorrect
Previous Message David Rowley 2017-05-15 04:05:07 Re: Commenting a FK crashes ALTER TABLE statements