From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: keith.fiske@crunchydata.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15865: ALTER TABLE statements causing "relation already exists" errors when some indexes exist
Date: Thu, 20 Jun 2019 20:20:55 -0400
Message-ID: <905.1561076455@sss.pgh.pa.us> (raw)
In-Reply-To: <25354.1561064909@sss.pgh.pa.us>
References: <20190620204505.GA22934@alvherre.pgsql>
<25354.1561064909@sss.pgh.pa.us>
I wrote:
> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
>> commit e76de886157b7f974d4d247908b242607cfbf043
>> Author: Tom Lane <tgl@sss.pgh.pa.us>
>> AuthorDate: Wed Jun 12 12:29:24 2019 -0400
>> CommitDate: Wed Jun 12 12:29:39 2019 -0400
>> Fix ALTER COLUMN TYPE failure with a partial exclusion constraint.
> Yeah, obviously I fat-fingered something there. Looking ...
Sigh ... so the answer is that I added the cleanup code (lines
10831..10864 in HEAD) in the wrong place. Putting it in
ATExecAlterColumnType is wrong because that gets executed potentially
multiple times per ALTER command, but I'd coded the cleanup assuming
that it would run only once. So we can end up with duplicate entries
in the changedIndexDefs list.
The right place to put it is in ATPostAlterTypeCleanup, of course.
(I think we could eliminate the changedIndexDefs list altogether and
just build the index-defining commands in the loop that uses them.)
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?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, 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: <905.1561076455@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox