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 1vTNEg-0005Iy-0E for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Dec 2025 16:40:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vTNEg-00CpZ9-00 for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Dec 2025 16:40:18 +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 1vTNEf-00CpZ1-2N for pgsql-bugs@lists.postgresql.org; Wed, 10 Dec 2025 16:40:18 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vTNEd-004AJZ-34 for pgsql-bugs@lists.postgresql.org; Wed, 10 Dec 2025 16:40:16 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b79af62d36bso546333066b.3 for ; Wed, 10 Dec 2025 08:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765384814; x=1765989614; 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=pmkhs1/NNgk+IGjqnUWVWdmKqmzQj8oSAGoKFlkdrrw=; b=eIs7fkiDntfX1hG/nGFh3EVY8f13SgzsjHKn3F7f/7fpM4py0p5YAubjIdCBbnY4d2 hHI0vaTIrVf8kKTTQEV5pIP7vXUcGb1/MJa5mgTqM+KwfiCgVGeetpPKedF/LYlfhWZD gJBieBa0Gex8rIHFdnPm2as7YKlFlcaaZgBjWectaqtos4SmrFXb+5PGlQb5UYeOfm99 qcQUjeTVPpz9yr2IrOezzrw6mIhqK4IetL0BMxJLjOnlCNeFeV8y8HlJaeRB5hzoc5a/ Mu61DTWeoW6XqAUqgh0wiCjOA25O9knzRmXyFKB2xkT6ahYnivhCY5V0+JhplBb5FQwO SDgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765384814; x=1765989614; 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=pmkhs1/NNgk+IGjqnUWVWdmKqmzQj8oSAGoKFlkdrrw=; b=sG8jfwMgOqgHr3ZDHOaqdvIzjOxmZFG6dLsUjAnLoUuqlPbRIp9dLIE+ErgCdRD+0u DpEoKs2bSoh1Y9aZc11pzIz+IsghERbxjni30RQORR371YG64MU2rj7maEP0pRT9qXtd WhTy/HIIKhfTDNvKkP8nSB/V3wGYbD0gPpT42jBsUmnC1UWx12DN9jLCid5UheVeauSp 7MEFMcFsgHi+WsIBJSDm5IcXhbkjzIkLWhahNtjYopaXnriM5T74EZVwbT9ZVIYxLGrc LbYuddA3MRXkWBx+18MKLg25bx+L+QbFddoLiH20Cb4iQcxfVduQtWw36eoIG6P/Jtv+ ta0Q== X-Forwarded-Encrypted: i=1; AJvYcCWU3qadS2mLJ+dq/UWa/1P4aQbu3IqmIWVoOw2B/1j6z3TVx+H1BbElzs5Ceqmnkc+7+Xw+Z0AeCqCV@lists.postgresql.org X-Gm-Message-State: AOJu0YxB0HXJ354D+W24xL6vsQUXn/WdXLT8x32xDkBrLNBiI8/Vs+IZ JoI5UZuNVZj+7GmmeKXmtKGEYdYCYXpIi3kYGlco2bMg8VB5oL96wNhClhyOAnEgqZDRzW6gpTh C4lgCMI95o6if0e/qtMtziLEwyZJ8lTYfIOWG X-Gm-Gg: AY/fxX4h1ZjuUURyJoUB4BsfVAeIcFj7qXrmS7bnoa/7yvVg9fapE8V9Qz2zaNvFMkX wJpEI6YhlNxAyoFvTpM5LGUAv6YkFMJTTuIBcUXPNVoViGWr0GRYO5HZqKkLBSljugPrTCQu1bZ IJ1TcV45niRRic6PJZl6xtxFDS1+jZzeIWUGJwuh6O49ZFnpEvsL3KP3BmG39nJ094c3rSgFQlJ WyPNazE3nWQQPnW4d2ffiKCSXcsykZXM21e28RCsa/35uqGhoUZWPLBnbR9s5XlMOww/lfMf2Gu H98cbNE8WIRqioDaqR2szwjR0ava6RQYdBUwpDrFM0gF2RCF7ydzsFjI5qHeuYSdXalfaUxPzZx Wc1HofRBONT0KZufRZLRwmed1JY2kT4l1mQQVEe84ULrZq3I= X-Google-Smtp-Source: AGHT+IGCmOKgeYqf/1JQ5H4QMx6XrOHsoICc9cxIG7yLlPT9jzqFUORfwuOD9oy09CETSRujVEoaWjLatp1+D1GWvfE= X-Received: by 2002:a17:907:2d89:b0:b7a:1be1:821 with SMTP id a640c23a62f3a-b7ce84c0ad4mr345296566b.62.1765384813732; Wed, 10 Dec 2025 08:40:13 -0800 (PST) MIME-Version: 1.0 References: <19351-8f1c523ead498545@postgresql.org> In-Reply-To: From: Srinath Reddy Sadipiralla Date: Wed, 10 Dec 2025 22:10:02 +0530 X-Gm-Features: AQt7F2rrknFuk8QZ-kDmTarTaIcV7oygDviiviOtM6g_pPngp2Oaj6Xb6az4WTY 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="000000000000b6e6a906459baeb7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b6e6a906459baeb7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 10, 2025 at 9:32=E2=80=AFPM 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? --=20 Thanks, Srinath Reddy Sadipiralla EDB: https://www.enterprisedb.com/ --000000000000b6e6a906459baeb7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


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

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

--
Thanks,
= Srinath Reddy Sadipiralla
EDB:=C2=A0https://www.enterprisedb.com/
--000000000000b6e6a906459baeb7--