Re: BUG #15865: ALTER TABLE statements causing "relation already exists" errors when some indexes exist

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Keith Fiske <keith(dot)fiske(at)crunchydata(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15865: ALTER TABLE statements causing "relation already exists" errors when some indexes exist
Date: 2019-06-24 19:05:30
Message-ID: 14787.1561403130@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

I wrote:
> As before, I attach a patch against HEAD, plus one that assumes e76de8861
> has been reverted first, which is likely easier to review.
> Unlike yesterday, I'm feeling pretty good about this patch now, but it
> still wouldn't hurt for somebody else to go over it.

I started to back-patch this, and soon noticed that the content of the
OCLASS_CONSTRAINT case branch in ATExecAlterColumnType has varied across
versions, which makes copy-and-pasting it seem pretty hazardous. Hence
it seems prudent to do slightly more work and split that code out into
a subroutine rather than having two copies. As attached, which is a
hopefully-final patch for HEAD. As before, it presumes reversion of
e76de8861, because it's a lot easier to see what's going on that way.

BTW ... while working on this, I got annoyed by the fact that
ATExecAlterColumnGenericOptions was inserted, no doubt with the aid of a
dartboard, into the middle of a large group of AlterColumnType-related
functions. Would anyone mind a separate patch to relocate it down
past those, probably just before ATExecChangeOwner?

regards, tom lane

Attachment Content-Type Size
alter-type-final-fix-HEAD.patch text/x-diff 9.3 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2019-06-24 22:59:03 Re: BUG #15869: Custom aggregation returns null when parallelized
Previous Message Kassym Dorsel 2019-06-24 16:07:20 Re: BUG #15869: Custom aggregation returns null when parallelized

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2019-06-24 19:06:25 Re: [PATCH] Stop ALTER SYSTEM from making bad assumptions
Previous Message Alvaro Herrera 2019-06-24 19:03:17 Re: Ear on mailing