From: | Hamid Akhtar <hamid(dot)akhtar(at)gmail(dot)com> |
---|---|
To: | dperham(at)opex(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary |
Date: | 2021-01-05 15:05:46 |
Message-ID: | CANugjhvFEDe8Hp7oUmCEZgXBrVNZn5NZgVL8=tUw+U8RwJ1Uww@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
I'm unable to reproduce this issue on CentOS7. Here's what I get:
------------------------------------------------------------
psql (12.5)
Type "help" for help.
postgres=# create table foo ( bar text );
CREATE TABLE
postgres=# alter table if exists foo add column if not exists id bigserial;
ALTER TABLE
postgres=# alter table if exists foo add column if not exists id bigserial;
NOTICE: column "id" of relation "foo" already exists, skipping
ALTER TABLE
------------------------------------------------------------
Can you please confirm if you are building from source or using any
standard postgresql packages?
On Tue, Jan 5, 2021 at 2:55 PM PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:
> The following bug has been logged on the website:
>
> Bug reference: 16805
> Logged by: Doug Perham
> Email address: dperham(at)opex(dot)com
> PostgreSQL version: 12.5
> Operating system: Ubuntu 20.04
> Description:
>
> ALTER TABLE IF EXIST foo ADD COLUMN IF NOT EXISTS id BIGSERIAL PRIMARY
> KEY;
> Fails if "id" exists and is already the primary key.
>
> It seems that everything should be okay if "id" exists and is the primary
> key. Instead, an error is thrown as follows:
>
>
> test=# create table foo ( bar text );
> CREATE TABLE
> test=# alter table if exists foo add column if not exists id bigserial
> primary key;
> ALTER TABLE
> test=# alter table if exists foo add column if not exists id bigserial
> primary key;
> NOTICE: column "id" of relation "foo" already exists, skipping
> ERROR: multiple primary keys for table "foo" are not allowed
>
>
--
Highgo Software (Canada/China/Pakistan)
URL : www.highgo.ca
ADDR: 10318 WHALLEY BLVD, Surrey, BC
CELL:+923335449950 EMAIL: mailto:hamid(dot)akhtar(at)highgo(dot)ca
SKYPE: engineeredvirus
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-01-05 15:45:02 | Re: BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary |
Previous Message | PG Bug reporting form | 2021-01-05 14:47:55 | BUG #16806: postgresql10 rpm is installed in the wrong directory |