Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vTMef-0017hM-0p for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Dec 2025 16:03:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vTMed-00Camf-2A for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Dec 2025 16:03:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vTMed-00CamU-0n for pgsql-bugs@lists.postgresql.org; Wed, 10 Dec 2025 16:03:03 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vTMeb-0049tk-1Q for pgsql-bugs@lists.postgresql.org; Wed, 10 Dec 2025 16:03:02 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-b7277324054so1056888666b.0 for ; Wed, 10 Dec 2025 08:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765382580; x=1765987380; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=+T1LtTDWSX10/VMnMNodP5umg5pVmaGRGmiAeujDzJA=; b=hVMpHAT1GE1sIpc70AT3wkykc2Nuqr0KJk9AKVlfvf278bgnrAAIZHXhzu8ZrsphGN MgBAdE0ElZapLP3Z7zyye7fLL2uueb9XwRTk9bzyX2/fJcWcAEc1yDZV273zk7DEMofS nMHMYxi5fNgp/Sllz0oMdGDeMw6B8g3qgnK4zg9dUeRpIIuS2czK9Oin4/isH0Eo826i Fuz7wpiq+wEra/HZtQngFAzfiTTfc4Fumc6psP23mIjoc4e69Qhvl6xQXOuWrGLPaYwL clJHGhVeZ6rNiXxcEAP0UftUpg0Wo7Ykd5dH5X7DS7WjTu5Hd9L740w5Jqu58GrXqm2r Xjig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765382580; x=1765987380; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+T1LtTDWSX10/VMnMNodP5umg5pVmaGRGmiAeujDzJA=; b=mew5dndDhH3lnc0aKENuWkauJ9lsqlk0lDL8MBXg/5BY9JT7B5KjtRoh/anoIWfwuU hmtnFCdA/Hcwp3QdafE3Ex0euHIKWdAK87jOzcpghcot2GXGr0+RUQ9dYYd8YpC13KTC Vgu5ecz5CWc5aYWc+lO3JbYrOjWZzk4OYZMtDp5crJGaPO/rOTXBkf45hmjvVe18I0PA eyaNc++VUnqhcZSUsq7Z7pZ5lQpJhZZx52OuDQQBgKQoTPsv9tga9yda/BsxIhWUTDlp 6cEoUrR6z4DS68/OMJelhgF346ajzfOcYmGAPmi+JztmLVb1kMwjFgjlrSjU2U2sDFWi GyLw== X-Forwarded-Encrypted: i=1; AJvYcCXQdTZ+JIlBAA7eDmYXOfmiPhX9osF+1Sp8REKkfMOuWnlOsviQNxSbemCnkmSTXrbDj92VdEiBTs57@lists.postgresql.org X-Gm-Message-State: AOJu0YyMLNH7+zlpOjFh7068PHYBIovheLcgjhJtQA/mgrsJ/DsH6mzT Kijbzo0i7+hvf8SLD4+szWp7gz/26vVMwuq7G+vRe7JTIUlU4gSSK6DrSwgO3WXve/i6xpaLiEV SoLRpLDB8ffJPflii7dQhJ6ebXR2xEawpejWL X-Gm-Gg: AY/fxX4v0ViI7F/5TWaYVtBnk23ChcM6nSnvDa2XQv4pPVD3jz2GrTApIVtVpltGpro FEM3CwD3tmH+WBoYDIdenA69Pv3XF9HHi25pDk931tJNA9OxVo83yFUa9MfAU0yH/u+KEFVpR0g LOl0T6paTQa8+ztUFcUnLvORN8agmlsml+z1JGGZV54leX+G856ref4XCqw3Sm9WuiYXHBHulom N02YbJ8WTOQA1ctfPe5N9xka24xgpyOX+yp1Q2n1pu5/aZi7CyW82H5oGIl2pV96YTg/+HdLvNE kVKNDlXMdBkLjllebEhxe5cKyvlw1as9ot2wAY5ebBVG9VQ2zSwRRSAVemm8AQsL8UwoeRdF0OW KTxamS+yGeagvU0Y9lrE0XdP9C+JzkQbRcRiS+8PLmdvFLxg= X-Google-Smtp-Source: AGHT+IGQbIF7nhm9fex9XJNfvZwaSb445XyPhtXSu+gXMRdbLLl4w1GcpjtpkaafMgiAeNtw1l1ECgo3hVubIVVGV5U= X-Received: by 2002:a17:906:6a09:b0:b79:c460:39a4 with SMTP id a640c23a62f3a-b7ce84339d5mr328983266b.56.1765382579304; Wed, 10 Dec 2025 08:02:59 -0800 (PST) MIME-Version: 1.0 References: <19351-8f1c523ead498545@postgresql.org> In-Reply-To: <19351-8f1c523ead498545@postgresql.org> From: Srinath Reddy Sadipiralla Date: Wed, 10 Dec 2025 21:32:46 +0530 X-Gm-Features: AQt7F2qprtV0qLBTlyOZyVgiz_MgfAYzSSpGBVpBcmD5qxrEvik2ejCKiaclflE Message-ID: Subject: Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem. To: msdnchina@163.com, pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000883fe506459b292e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000883fe506459b292e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Wed, Dec 10, 2025 at 8:52=E2=80=AFPM PG Bug reporting form < noreply@postgresql.org> wrote: > The following bug has been logged on the website: > > Bug reference: 19351 > Logged by: yanliang lei > Email address: msdnchina@163.com > PostgreSQL version: 18.1 > Operating system: Linux > Description: > > postgres=3D# create table test_null_20251210(c1 int not null,c2 text); > CREATE TABLE > postgres=3D# \d+ test_null_20251210 > =E6=95=B0=E6=8D=AE=E8=A1=A8 "public.test_null_2025= 1210" > =E6=A0=8F=E4=BD=8D | =E7=B1=BB=E5=9E=8B | =E6=A0=A1=E5=AF=B9=E8=A7=84= =E5=88=99 | =E5=8F=AF=E7=A9=BA=E7=9A=84 | =E9=A2=84=E8=AE=BE | =E5=AD= =98=E5=82=A8 | =E5=8E=8B=E7=BC=A9 | =E7=BB=9F=E8=AE=A1=E7=9B=AE=E6=A0=87 = | =E6=8F=8F=E8=BF=B0 > > ------+---------+----------+----------+------+----------+------+---------= -+------ > c1 | integer | | not null | | plain | | = | > c2 | text | | | | extended | | = | > Not-null constraints: > "test_null_20251210_c1_not_null" NOT NULL "c1" > =E8=AE=BF=E9=97=AE=E6=96=B9=E6=B3=95 heap > > postgres=3D# alter table test_null_20251210 add constraint xyzxyz not nu= ll > c1; > ALTER TABLE > <<<--- above alter table statement should report 'not null constraint > exists', > <<<---- Maybe this problem is a bug ? > postgres=3D# \d+ test_null_20251210 > =E6=95=B0=E6=8D=AE=E8=A1=A8 "public.test_null_2025= 1210" > =E6=A0=8F=E4=BD=8D | =E7=B1=BB=E5=9E=8B | =E6=A0=A1=E5=AF=B9=E8=A7=84= =E5=88=99 | =E5=8F=AF=E7=A9=BA=E7=9A=84 | =E9=A2=84=E8=AE=BE | =E5=AD= =98=E5=82=A8 | =E5=8E=8B=E7=BC=A9 | =E7=BB=9F=E8=AE=A1=E7=9B=AE=E6=A0=87 = | =E6=8F=8F=E8=BF=B0 > > ------+---------+----------+----------+------+----------+------+---------= -+------ > c1 | integer | | not null | | plain | | = | > c2 | text | | | | extended | | = | > Not-null constraints: > "test_null_20251210_c1_not_null" NOT NULL "c1" > =E8=AE=BF=E9=97=AE=E6=96=B9=E6=B3=95 heap > > postgres=3D# select version(); > version > > -------------------------------------------------------------------------= ---------- > PostgreSQL 18.1 on aarch64-unknown-linux-gnu, compiled by gcc (GCC) 7.3.= 0, > 64-bit > (1 =E8=A1=8C=E8=AE=B0=E5=BD=95) > > postgres=3D# > > 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=3Dchatgpt.com#= DDL-ALTER-ADDING-A-CONSTRAINT --=20 Thanks, Srinath Reddy Sadipiralla EDB: https://www.enterprisedb.com/ --000000000000883fe506459b292e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Wed, Dec 10, = 2025 at 8:52=E2=80=AFPM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on= the website:

Bug reference:=C2=A0 =C2=A0 =C2=A0 19351
Logged by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 yanliang lei
Email address:=C2=A0 =C2=A0 =C2=A0 msdnchina@163.com
PostgreSQL version: 18.1
Operating system:=C2=A0 =C2=A0Linux
Description:=C2=A0 =C2=A0 =C2=A0 =C2=A0

postgres=3D# create table test_null_20251210(c1 int not null,c2 text);
CREATE TABLE
postgres=3D# \d+ test_null_20251210
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0=E6=95=B0=E6=8D=AE=E8=A1=A8 "public.test_null_20251210"=
=C2=A0=E6=A0=8F=E4=BD=8D |=C2=A0 =E7=B1=BB=E5=9E=8B=C2=A0 =C2=A0| =E6=A0=A1= =E5=AF=B9=E8=A7=84=E5=88=99 |=C2=A0 =E5=8F=AF=E7=A9=BA=E7=9A=84=C2=A0 | =E9= =A2=84=E8=AE=BE |=C2=A0 =C2=A0=E5=AD=98=E5=82=A8=C2=A0 =C2=A0| =E5=8E=8B=E7= =BC=A9 | =E7=BB=9F=E8=AE=A1=E7=9B=AE=E6=A0=87 | =E6=8F=8F=E8=BF=B0
------+---------+----------+----------+------+----------+------+----------+= ------
=C2=A0c1=C2=A0 =C2=A0| integer |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not nu= ll |=C2=A0 =C2=A0 =C2=A0 | plain=C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 |=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
=C2=A0c2=C2=A0 =C2=A0| text=C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 | extended |= =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
Not-null constraints:
=C2=A0 =C2=A0 "test_null_20251210_c1_not_null" NOT NULL "c1&= quot;
=E8=AE=BF=E9=97=AE=E6=96=B9=E6=B3=95 heap

postgres=3D# alter table test_null_20251210 add=C2=A0 constraint xyzxyz not= null
c1;
ALTER TABLE
<<<--- above=C2=A0 alter table statement should report 'not nu= ll constraint
exists',
<<<---- Maybe this problem is a bug ?
postgres=3D# \d+ test_null_20251210
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0=E6=95=B0=E6=8D=AE=E8=A1=A8 "public.test_null_20251210"=
=C2=A0=E6=A0=8F=E4=BD=8D |=C2=A0 =E7=B1=BB=E5=9E=8B=C2=A0 =C2=A0| =E6=A0=A1= =E5=AF=B9=E8=A7=84=E5=88=99 |=C2=A0 =E5=8F=AF=E7=A9=BA=E7=9A=84=C2=A0 | =E9= =A2=84=E8=AE=BE |=C2=A0 =C2=A0=E5=AD=98=E5=82=A8=C2=A0 =C2=A0| =E5=8E=8B=E7= =BC=A9 | =E7=BB=9F=E8=AE=A1=E7=9B=AE=E6=A0=87 | =E6=8F=8F=E8=BF=B0
------+---------+----------+----------+------+----------+------+----------+= ------
=C2=A0c1=C2=A0 =C2=A0| integer |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not nu= ll |=C2=A0 =C2=A0 =C2=A0 | plain=C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 |=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
=C2=A0c2=C2=A0 =C2=A0| text=C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 | extended |= =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
Not-null constraints:
=C2=A0 =C2=A0 "test_null_20251210_c1_not_null" NOT NULL "c1&= quot;
=E8=AE=BF=E9=97=AE=E6=96=B9=E6=B3=95 heap

postgres=3D# select version();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 version
---------------------------------------------------------------------------= --------
=C2=A0PostgreSQL 18.1 on aarch64-unknown-linux-gnu, compiled by gcc (GCC) 7= .3.0,
64-bit
(1 =E8=A1=8C=E8=AE=B0=E5=BD=95)

postgres=3D#


It's an expected behavior; you can check he= re [0],
but i am curious ,why it's not treated as normal
constrai= nt and why we are not throwing an error
like the constraint already exis= ts?

[0]=C2=A0https://www.p= ostgresql.org/docs/18/ddl-alter.html?utm_source=3Dchatgpt.com#DDL-ALTER-ADD= ING-A-CONSTRAINT

--
Thanks,
Srinath Reddy Sadipiralla<= /span>
EDB:=C2=A0https://www.enterprisedb.com/
--000000000000883fe506459b292e--