From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | dperham(at)opex(dot)com |
Subject: | BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary |
Date: | 2021-01-05 01:23:04 |
Message-ID: | 16805-4e3f8b42fbe7622c@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: 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
From | Date | Subject | |
---|---|---|---|
Next Message | baych igor | 2021-01-05 14:06:18 | compiling error on OpenWrt |
Previous Message | Tom Lane | 2021-01-04 22:28:11 | Re: BUG #16804: substring() function returns "negative substring length" error when using a large length argument |