Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem. - Mailing list pgsql-bugs

From Srinath Reddy Sadipiralla
Subject Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.
Date
Msg-id CAFC+b6q7xFQN=wRP0rOCLat=rWNNNhuhEKOUV-2BJ9HxU5SrAQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.  (Srinath Reddy Sadipiralla <srinath2133@gmail.com>)
Responses Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.
List pgsql-bugs


On Wed, Dec 10, 2025 at 9:32 PM Srinath Reddy Sadipiralla <srinath2133@gmail.com> wrote:
why it's not treated as normal
constraint and why we are not throwing an error
like the constraint already exists?

ah... just after a quick code lookup, remembered that
"not null" is treated as a column property, which is a
flag in pg_attribute catalog table named as "attnotnull",
i guess the reason(s) it's a column property rather than
constraint might be an overkill, adds overhead of entries
in pg_constraint, or historical reasons, please correct me
if i am wrong, still the right way of setting this constraint "ALTER TABLE test_null_20251210 ALTER COLUMN c1 SET NOT NULL;"
not throwing an error; i think it makes sense to throw an
error here, thoughts?

--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC
Next
From: "Haowu Ge"
Date:
Subject: Re: GROUP BY ROLLUP queries on views trigger full table scans (index usage not optimized)