pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: dafoer_x@163.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.
Date: Tue, 12 Apr 2022 10:41:46 -0400
Message-ID: <795093.1649774506@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwYwhyZDkR2RmQ8ns7p=gVjBumU_Broh_VC9JMTkOpcotA@mail.gmail.com>
References: <17464-4751c9d69159f363@postgresql.org>
	<CAKFQuwYwhyZDkR2RmQ8ns7p=gVjBumU_Broh_VC9JMTkOpcotA@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> "VALUES = 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 be
> 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=# set transform_null_equals = 1;
SET
regression=# CREATE DOMAIN xb AS TEXT CHECK
regression-# (
regression(#    VALUE = '男'
regression(#    OR VALUE ='女'
regression(#    OR VALUE = null
regression(#  );
CREATE DOMAIN
regression=# \dD+ xb
                                                                       List of domains
 Schema | Name | Type | Collation | Nullable | Default |                               Check                                | Access privileges | Description 
--------+------+------+-----------+----------+---------+--------------------------------------------------------------------+-------------------+-------------
 public | xb   | text |           |          |         | CHECK (VALUE = '男'::text OR VALUE = '女'::text OR VALUE IS NULL) |                   | 
(1 row)


			regards, tom lane





view thread (3+ messages)

Message-ID: <795093.1649774506@sss.pgh.pa.us>
Permalink:  ../795093.1649774506@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/795093.1649774506@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.
  In-Reply-To: <795093.1649774506@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox