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.94.2) (envelope-from ) id 1tVfBT-00AOpG-86 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 23:09:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tVfBR-008P5r-UB for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 23:09:53 +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.94.2) (envelope-from ) id 1tVfBR-008P5j-Hi for pgsql-hackers@lists.postgresql.org; Wed, 08 Jan 2025 23:09:53 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tVfBO-000cpx-0h for pgsql-hackers@lists.postgresql.org; Wed, 08 Jan 2025 23:09:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2025010100; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=3rA5RUo7IIDvZ0BWGn682rMo5B92UKwTkAIx1tTydtI=; b=kQjfx O5JB/gxGSAUHv+qkDeO2lVZKZ8aus80k0AM8d6wPYlwsph4/b4MoUtrtTK0lN8iqaE5xYec6eWdn5 MNrykpGO8ZC3Z9MrPv/Uq8yJrEd9jM4HVL3EJOviT627QapVDwBOGDvlPG39Vmoh3aYLV9h27mEjg oFWPwC+fuyO6Fb/9x7ptOtMjt6C3JmdMfHV4rHOCnGR+Lrm4QOy5iFIybJ9HAacy7V3gFysQy55Ta iBPeu71PSWdcv+X5A3tqNFkiQxzMKGd4Bu/OWizgqlWTMMp5Xyk452Jr/cikFLWnLJfRzzw1Uakcm /V8vxCirjKG/b7iHLRvGTQrmeaUuQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1tVfBL-002r2c-0C; Wed, 08 Jan 2025 18:09:47 -0500 Date: Wed, 8 Jan 2025 18:09:47 -0500 From: Bruce Momjian To: Tom Lane Cc: jbe-mlist@magnetkern.de, PostgreSQL-development Subject: Re: Parameter NOT NULL to CREATE DOMAIN not the same as CHECK (VALUE IS NOT NULL) Message-ID: References: <173591158454.714.7664064332419606037@wrigleys.postgresql.org> <1694911.1736371474@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="4XCntcNbmG6aPE/s" Content-Disposition: inline In-Reply-To: <1694911.1736371474@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --4XCntcNbmG6aPE/s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jan 8, 2025 at 04:24:34PM -0500, Tom Lane wrote: > Bruce Momjian writes: > > I think this needs some serious research. > > We've discussed this topic before. The spec's definition of IS [NOT] > NULL for composite values is bizarre to say the least. I think > there's been an intentional choice to keep most NOT NULL checks > "simple", that is we look at the overall value's isnull bit and > don't probe any deeper than that. > > If the optimizations added in v17 changed existing behavior, > I agree that's bad. We should probably fix it so that those > are only applied when argisrow is false. Okay, makes sense. Do we have any sense of whether the docs can be improved in this area, based on the original email report? Here is a proposed patch for that. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Do not let urgent matters crowd out time for investment in the future. --4XCntcNbmG6aPE/s Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="domain.diff" diff --git a/doc/src/sgml/ref/create_domain.sgml b/doc/src/sgml/ref/create_domain.sgml index ce555203486..c111285a69c 100644 --- a/doc/src/sgml/ref/create_domain.sgml +++ b/doc/src/sgml/ref/create_domain.sgml @@ -283,7 +283,8 @@ CREATE TABLE us_snail_addy ( The syntax NOT NULL in this command is a PostgreSQL extension. (A standard-conforming - way to write the same would be CHECK (VALUE IS NOT + way to write the same for non-composite data types would be + CHECK (VALUE IS NOT NULL). However, per , such constraints are best avoided in practice anyway.) The NULL constraint is a --4XCntcNbmG6aPE/s--