42P16 error when dropping and adding column - Mailing list pgsql-bugs

From Ludvig Janiuk
Subject 42P16 error when dropping and adding column
Date
Msg-id 0a9b4c44-cdff-4ec8-a8fb-b3a8b59e9ba9@proton.me
Whole thread
Responses Re: 42P16 error when dropping and adding column
List pgsql-bugs
Hello, it seems that between pqsl 17 and 18, the behavior of the
following reproducer has changed:

====
CREATE TABLE reproducer(id int NOT NULL); ALTER TABLE reproducer DROP
COLUMN "id", ADD COLUMN "id" int, ADD PRIMARY KEY("id");
====

Expected output (this is the case on psql 16 and 17):

====
CREATE TABLE
ALTER TABLE
====

Actual output (on psql (PostgreSQL) 18.6 (Ubuntu 18.6-0ubuntu0.26.04.1)):

====
CREATE TABLE
ERROR:  42P16: primary key column "id" is not marked NOT NULL
LOCATION:  index_check_primary_key, index.c:266
====

I could not find anything direcly related in the change notes
(https://www.postgresql.org/docs/release/18.0/). There were a few lines
related to NULL, but with my knowledge I could not be sure if they were
relevant.

I hope you can accept my bug report, or let me know the reason why if
this is correct behavior.

Best regards,

--
//Ludvig Janiuk





pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19692: Generic partition-pruning plan delays statement_timeout cancellation
Next
From: Fujii Masao
Date:
Subject: Re: 42P16 error when dropping and adding column