Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heMhr-0000cU-Rl for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2019 16:48:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1heMhp-0005Bf-Td for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2019 16:48:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heMhp-00057s-K7 for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2019 16:48:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heMhl-0003zl-Vc for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2019 16:48:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x5LGlt65021082; Fri, 21 Jun 2019 12:47:55 -0400 From: Tom Lane To: Alvaro Herrera cc: keith.fiske@crunchydata.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15865: ALTER TABLE statements causing "relation already exists" errors when some indexes exist In-reply-to: <28827.1561082086@sss.pgh.pa.us> References: <20190620204505.GA22934@alvherre.pgsql> <25354.1561064909@sss.pgh.pa.us> <905.1561076455@sss.pgh.pa.us> <28827.1561082086@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 20 Jun 2019 21:54:46 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21080.1561135675.1@sss.pgh.pa.us> Date: Fri, 21 Jun 2019 12:47:55 -0400 Message-ID: <21081.1561135675@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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