BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary
Дата
Msg-id 16805-4e3f8b42fbe7622c@postgresql.org
обсуждение исходный текст
Ответы Re: BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary  (Hamid Akhtar <hamid.akhtar@gmail.com>)
Re: BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16805
Logged by:          Doug Perham
Email address:      dperham@opex.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


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16804: substring() function returns "negative substring length" error when using a large length argument
Следующее
От: baych igor
Дата:
Сообщение: compiling error on OpenWrt