pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: greg.amer@smxemail.com
Subject: BUG #15915: ALTER COLUMN SET DATA TYPE fails with index already exists
Date: Thu, 18 Jul 2019 03:51:52 +0000
Message-ID: <15915-f692f7414eafb1bd@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15915
Logged by:          Greg Amer
Email address:      greg.amer@smxemail.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



view thread (2+ messages)  latest in thread

Message-ID: <15915-f692f7414eafb1bd@postgresql.org>
Permalink:  ../15915-f692f7414eafb1bd@postgresql.org/
Also on:    postgresql.org/message-id/15915-f692f7414eafb1bd@postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, greg.amer@smxemail.com
  Subject: Re: BUG #15915: ALTER COLUMN SET DATA TYPE fails with index already exists
  In-Reply-To: <15915-f692f7414eafb1bd@postgresql.org>
  References: <15915-f692f7414eafb1bd@postgresql.org>

* 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