Re: Altering multiple column types - Mailing list pgsql-general

From Luca Ferrari
Subject Re: Altering multiple column types
Date
Msg-id CAKoxK+55KJ9mnasQsTCdOXGty=nDPTqXOq_KUWRMhQDZ_BkjSg@mail.gmail.com
Whole thread Raw
In response to Re: Altering multiple column types  (Bharanee Rathna <deepfryed@gmail.com>)
List pgsql-general
On Fri, Aug 2, 2019 at 10:06 AM Bharanee Rathna <deepfryed@gmail.com> wrote:
>
> Hi Luca,
>
> testing this using docker images. I can replicate it with 10.9-alpine
>
> bash-5.0# psql -h127.0.0.1 -Upostgres test
> psql (10.9)
> Type "help" for help.
>
> test=# \d users
>                                     Table "public.users"
>  Column |          Type          | Collation | Nullable |              Default
> --------+------------------------+-----------+----------+-----------------------------------
>  id     | integer                |           | not null | nextval('users_id_seq'::regclass)
>  name   | character varying(255) |           |          |
>  age    | integer                |           |          |
>  email  | character varying(255) |           |          |
> Indexes:
>     "users_pkey" PRIMARY KEY, btree (id)
>     "users_email_idx" btree (email)
>     "users_name_idx" btree (name)

My fault!
I missed one index, so it is working with one index a two column alter
table, but not with two indexes:

testdb=# alter table users alter column name type text, alter column
email type text;
alter table users alter column name type text, alter column email type text;
psql: ERROR:  relation "users_name_idx" already exists


Therefore I think it is a strange behavior, I cannot explain.
I confirm the problem shows up in 11.4 and 12beta2, so I guess there's
must be a reason I don't understand.

Luca



pgsql-general by date:

Previous
From: Tony Shelver
Date:
Subject: Re: PGAdmin4.11.1 on Ubuntu 18.04
Next
From: Durumdara
Date:
Subject: PGSQL "macro" or "inplace subfunction"?