From: Ludvig Janiuk <ludvig.janiuk@proton.me>
To: pgsql-bugs@lists.postgresql.org
Subject: 42P16 error when dropping and adding column
Date: Thu, 17 Sep 2026 09:51:54 +0000
Message-ID: <0a9b4c44-cdff-4ec8-a8fb-b3a8b59e9ba9@proton.me> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: ludvig.janiuk@proton.me, pgsql-bugs@lists.postgresql.org
Subject: Re: 42P16 error when dropping and adding column
In-Reply-To: <0a9b4c44-cdff-4ec8-a8fb-b3a8b59e9ba9@proton.me>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox