Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1neHic-0000BF-NV for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Apr 2022 14:42:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1neHib-0002or-Lr for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Apr 2022 14:42:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1neHib-0002og-Dl for pgsql-bugs@lists.postgresql.org; Tue, 12 Apr 2022 14:42:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1neHiZ-0005oJ-8P for pgsql-bugs@lists.postgresql.org; Tue, 12 Apr 2022 14:42:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 23CEfkn4795094; Tue, 12 Apr 2022 10:41:46 -0400 From: Tom Lane To: "David G. Johnston" cc: dafoer_x@163.com, PostgreSQL mailing lists Subject: Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted. In-reply-to: References: <17464-4751c9d69159f363@postgresql.org> Comments: In-reply-to "David G. Johnston" message dated "Tue, 12 Apr 2022 07:27:44 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <795092.1649774506.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 12 Apr 2022 10:41:46 -0400 Message-ID: <795093.1649774506@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > "VALUES =3D null" is simply wrong. That isn't how one checks for null. = Use > "IS NULL". If that restores the correct behavior I'm unsure what we'd b= e > willing to do to behave differently in the presence of the improper null > test form. There's already transform_null_equals, which does work if you turn it on while executing this incorrect CREATE DOMAIN command. But the better answer is to fix your SQL. regression=3D# set transform_null_equals =3D 1; SET regression=3D# CREATE DOMAIN xb AS TEXT CHECK regression-# ( regression(# VALUE =3D '=E7=94=B7' regression(# OR VALUE =3D'=E5=A5=B3' regression(# OR VALUE =3D null regression(# ); CREATE DOMAIN regression=3D# \dD+ xb Lis= t of domains Schema | Name | Type | Collation | Nullable | Default | = Check | Access privileges | De= scription = --------+------+------+-----------+----------+---------+------------------= --------------------------------------------------+-------------------+---= ---------- public | xb | text | | | | CHECK (VALUE =3D = '=E7=94=B7'::text OR VALUE =3D '=E5=A5=B3'::text OR VALUE IS NULL) | = | = (1 row) regards, tom lane