Re: Altering multiple column types

From: Luca Ferrari <fluca1978(at)gmail(dot)com>
To: Bharanee Rathna <deepfryed(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Altering multiple column types
Date: 2019-08-02 08:58:49
Message-ID: CAKoxK+55KJ9mnasQsTCdOXGty=nDPTqXOq_KUWRMhQDZ_BkjSg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Aug 2, 2019 at 10:06 AM Bharanee Rathna <deepfryed(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Durumdara 2019-08-02 11:57:26 PGSQL "macro" or "inplace subfunction"?
Previous Message Tony Shelver 2019-08-02 08:32:55 Re: PGAdmin4.11.1 on Ubuntu 18.04