BUG #15915: ALTER COLUMN SET DATA TYPE fails with index already exists

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: greg(dot)amer(at)smxemail(dot)com
Subject: BUG #15915: ALTER COLUMN SET DATA TYPE fails with index already exists
Date: 2019-07-18 03:51:52
Message-ID: 15915-f692f7414eafb1bd@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15915
Logged by: Greg Amer
Email address: greg(dot)amer(at)smxemail(dot)com
PostgreSQL version: 9.6.14
Operating system: Centos 7
Description:

When attempting to set the data type on multiple columns in a single sql
where the columns have indexes, the alter call fails. This previously worked
on 9.6.6.

Example:

# CREATE TABLE a ( b VARCHAR(100), c VARCHAR(100));
CREATE TABLE
# CREATE INDEX a_idx ON a(b);
CREATE INDEX
# CREATE INDEX a1_idx ON a(c);
CREATE INDEX
# INSERT INTO a VALUES ('Test', 'Test');
INSERT 0 1
# ALTER TABLE a ALTER b TYPE text, ALTER c TYPE text;
ERROR: relation "a_idx" already exists

This contradicts the documentation (and previous behaviour)
"SET DATA TYPE
This form changes the type of a column of a table. Indexes and simple table
constraints involving the column will be automatically converted to use the
new column type by reparsing the originally supplied expression."

Note this works if only altering a single column
# ALTER TABLE a ALTER b TYPE text;
ALTER TABLE

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-07-18 03:57:03 Re: BUG #15915: ALTER COLUMN SET DATA TYPE fails with index already exists
Previous Message Michael Paquier 2019-07-18 03:02:32 Re: REINDEX CONCURRENTLY causes ALTER TABLE to fail