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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: dperham(at)opex(dot)com
Cc: 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:45:02
Message-ID: 3379436.1609861502@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> ALTER TABLE IF EXIST foo ADD COLUMN IF NOT EXISTS id BIGSERIAL PRIMARY KEY;
> Fails if "id" exists and is already the primary key.

Yeah, known problem. This is fixed in v13, but the fix seemed too
invasive for a back-patch (see [1] and follow-on fixes).

regards, tom lane

[1] https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=1281a5c90

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-01-05 15:49:33 Re: compiling error on OpenWrt
Previous Message Hamid Akhtar 2021-01-05 15:05:46 Re: BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary