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: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: keith(dot)fiske(at)crunchydata(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-21 16:47:55
Message-ID: 21081.1561135675@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

I wrote:
> BTW, has anyone got an explanation for the order in which psql is
> listing the indexes of "anothertab" in this test case?

Ah, here's the explanation: describe.c is sorting the indexes
with this:

"ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname;"

I can see the point of putting the pkey first, I guess, but the preference
for uniques second seems pretty bizarre, especially since
(a) it doesn't distinguish unique constraints from plain unique indexes and
(b) there's no similar preference for exclusion constraints, even though
those might be morally equivalent to a unique constraint.

What do people think of dropping the indisunique sort column here?
Obviously not back-patch material, but it might be more sensible
behavior going forward.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Keith Fiske 2019-06-21 17:06:19 Re: BUG #15865: ALTER TABLE statements causing "relation already exists" errors when some indexes exist
Previous Message Tom Lane 2019-06-21 16:12:00 Re: BUG #15865: ALTER TABLE statements causing "relation already exists" errors when some indexes exist

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-06-21 16:55:12 Re: [PATCH] Stop ALTER SYSTEM from making bad assumptions
Previous Message Stephen Frost 2019-06-21 16:40:28 Re: [PATCH] Stop ALTER SYSTEM from making bad assumptions