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

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>, keith.fiske@crunchydata.com, pgsql-bugs@lists.postgresql.org
Date: 2019-06-21T00:45:54Z
Lists: pgsql-bugs, pgsql-hackers
On Thu, Jun 20, 2019 at 08:20:55PM -0400, Tom Lane wrote:
> This is a pretty embarrassing bug, reinforcing my hindsight view
> that I was firing on very few cylinders last week.  It basically
> means that any ALTER TABLE that tries to alter the type of more than
> one column is going to fail, if any but the last such column has a
> dependent plain (non-constraint) index.  The test cases added by
> e76de8861 were oh so close to noticing that, but not close enough.
> 
> I'll go fix it, but do we need to consider a near-term re-release?

Ugh.  That's a possibility.  Changing each ALTER TABLE to be run
individually can be a pain, and we really ought to push for the fix of
the most recent CVE as soon as possible :(
--
Michael

Commits

  1. Simplify psql \d's rule for ordering the indexes of a table.

  2. Purely-cosmetic adjustments in tablecmds.c.

  3. Further fix ALTER COLUMN TYPE's handling of indexes and index constraints.

  4. Fix ALTER COLUMN TYPE failure with a partial exclusion constraint.