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 1vPuVT-001IfM-2y for pgsql-general@arkaria.postgresql.org; Mon, 01 Dec 2025 03:23: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 1vPuVR-00HYU9-2u for pgsql-general@arkaria.postgresql.org; Mon, 01 Dec 2025 03:23:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vPuVR-00HYU1-1q for pgsql-general@lists.postgresql.org; Mon, 01 Dec 2025 03:23:17 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vPuVP-002Qui-2C for pgsql-general@postgresql.org; Mon, 01 Dec 2025 03:23:17 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 87F331D000E3; Sun, 30 Nov 2025 22:23:13 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sun, 30 Nov 2025 22:23:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1764559393; x=1764645793; bh=eGeDiDSI4DPaEZyeTGt3JEqMesuBPGF0vGukQGUF6T8=; b= QcITmccLu2WTM4buFCbkyXgrre6vW8FCntZdpyG2/si8R4ZNWBd3BsvkMOrJdLXK HbPFvE3ZQVf/Ed44o2qb/1T9JO5kuT3W9RtSJW7pg6Zo/relqBv7YEe7ScBOk196 406VHduw8E2HJVDMkzDdJSjzjL1lZO1r6pCGt5iryGW0Tic+0Nvg54upLPQ5Vvrf YlTkDPu30mL6iSYREP35bd3F2U/yoiqGmDWfjhhAHP5vXzLms6QeQ2zb/mYWg+Ai Da7cmGBWE1y5NAzjxo2fsQ0iA4ViJAs4X6/Ot7nsG6t/OABB59ljMPhfPN0uA3zu +jVrWlE0IQ4PVy8da6Y5pA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1764559393; x=1764645793; bh=e GeDiDSI4DPaEZyeTGt3JEqMesuBPGF0vGukQGUF6T8=; b=Tk3bibkSsYpZDftlN Q3bIIy7cRyumXkIIo1+ogZj3d3hDxJAH9WRyAMBtgR0VKjNrIxTN+MJskYY3NNGN A5Kp6jidEhVxT4hPVTuVaNvYL848mFCroPcRfZs6aSITC45sBe5pmRX3/lMOt7FT tgySmYJQkzjKpRd0m1OTB6QY8zw/eV3ggwqaZHLURbmw9AfZJWnyp5kgIHofuS7s AiFN+OAY2XhQVP44vKQChca8iGYZM9p0/Y/X2QdIbG5FZh/nH0euiT7/zMYvPDNx smQgg/Tdi3rB6Uh1d3c8EsOYlUscK3K/lQ22Ia7OTN5uhUa4OAn5IxZvqKr3/Tkx BpKpQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvheeiiedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffhvfhfjggtgfesthejredttddvjeenucfhrhhomheptegurhhirghn ucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqe enucggtffrrghtthgvrhhnpeduffekleeuhefftdeiteektddtveevvdffieffudehgfeg tedtteehffeuteegfeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhoug gvpehsmhhtphhouhhtpdhrtghpthhtohepshhtuhgrrhhtrdgtrghmphgsvghllhesrhhi uggvfihithhhvhhirgdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlse hpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 30 Nov 2025 22:23:12 -0500 (EST) Message-ID: <301832e8-a3d7-46f5-9db5-691b71eee9ac@aklaver.com> Date: Sun, 30 Nov 2025 19:23:12 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Check whether a NOT NULL check constraint has been validated From: Adrian Klaver To: Stuart Campbell , pgsql-general@postgresql.org References: <1b930bcc-16f4-4c97-93f8-a21d314ba373@aklaver.com> Content-Language: en-US In-Reply-To: <1b930bcc-16f4-4c97-93f8-a21d314ba373@aklaver.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/30/25 19:07, Adrian Klaver wrote: > On 11/30/25 16:59, Stuart Campbell wrote: >> Hello, >> >> I have several NOT NULL check constraints in my schema that were >> originally added as NOT VALID. I would like to determine whether they >> have all since been validated, or not. >> >> I thought maybe pg_constraint.convalidated might help, but it seems >> like the version of Postgres I'm using (16) doesn't store not null >> constraints in that table. And even in later versions, maybe it >> doesn't hold the information I need. >> >> Is there another way to discover this? > > 1) Select count(*) from where IS NULL; > > 2) From here > > https://www.postgresql.org/docs/current/sql-altertable.html#SQL- > ALTERTABLE-NOTES > > ALTER TABLE
VALIDATE CONSTRAINT ; > > As described: > > ". Once the constraint is in place, no new violations can be inserted, > and the existing problems can be corrected at leisure until VALIDATE > CONSTRAINT finally succeeds." Realized I was looking at current docs and I should be looking at your version From the 16 version of the docs: "This form adds a new constraint to a table using the same constraint syntax as CREATE TABLE, plus the option NOT VALID, which is currently only allowed for foreign key and CHECK constraints." Now I am not sure what you did. Are you saying you used a CHECK constraint to check for NULL values? If so then pg_constraint.convalidated would work. If not are you sure you are on Postgres 16? > >> >> This communication and any attachments may contain confidential >> information and are intended to be viewed only by the intended >> recipients. If you have received this message in error, please notify >> the sender immediately by replying to the original message and then >> delete all copies of the email from your systems. >> >> > > -- Adrian Klaver adrian.klaver@aklaver.com