public inbox for [email protected]  
help / color / mirror / Atom feed
From: Srinath Reddy Sadipiralla <[email protected]>
To: [email protected]
To: [email protected]
Subject: Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.
Date: Wed, 10 Dec 2025 21:32:46 +0530
Message-ID: <CAFC+b6pA+zGmt_WoEMqHNRaAGVOU7KPyUuAFKnEdzeLW1KzzjQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

Hi,

On Wed, Dec 10, 2025 at 8:52 PM PG Bug reporting form <
[email protected]> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      19351
> Logged by:          yanliang lei
> Email address:      [email protected]
> PostgreSQL version: 18.1
> Operating system:   Linux
> Description:
>
> postgres=# create table test_null_20251210(c1 int not null,c2 text);
> CREATE TABLE
> postgres=# \d+ test_null_20251210
>                        数据表 "public.test_null_20251210"
>  栏位 |  类型   | 校对规则 |  可空的  | 预设 |   存储   | 压缩 | 统计目标 | 描述
>
> ------+---------+----------+----------+------+----------+------+----------+------
>  c1   | integer |          | not null |      | plain    |      |          |
>  c2   | text    |          |          |      | extended |      |          |
> Not-null constraints:
>     "test_null_20251210_c1_not_null" NOT NULL "c1"
> 访问方法 heap
>
> postgres=# alter table test_null_20251210 add  constraint xyzxyz not null
> c1;
> ALTER TABLE
> <<<--- above  alter table statement should report 'not null constraint
> exists',
> <<<---- Maybe this problem is a bug ?
> postgres=# \d+ test_null_20251210
>                        数据表 "public.test_null_20251210"
>  栏位 |  类型   | 校对规则 |  可空的  | 预设 |   存储   | 压缩 | 统计目标 | 描述
>
> ------+---------+----------+----------+------+----------+------+----------+------
>  c1   | integer |          | not null |      | plain    |      |          |
>  c2   | text    |          |          |      | extended |      |          |
> Not-null constraints:
>     "test_null_20251210_c1_not_null" NOT NULL "c1"
> 访问方法 heap
>
> postgres=# select version();
>                                       version
>
> -----------------------------------------------------------------------------------
>  PostgreSQL 18.1 on aarch64-unknown-linux-gnu, compiled by gcc (GCC) 7.3.0,
> 64-bit
> (1 行记录)
>
> postgres=#
>
>
It's an expected behavior; you can check here [0],
but i am curious ,why it's not treated as normal
constraint and why we are not throwing an error
like the constraint already exists?

[0]
https://www.postgresql.org/docs/18/ddl-alter.html?utm_source=chatgpt.com#DDL-ALTER-ADDING-A-CONSTRAI...

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


reply

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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.
  In-Reply-To: <CAFC+b6pA+zGmt_WoEMqHNRaAGVOU7KPyUuAFKnEdzeLW1KzzjQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox