Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted. - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.
Date
Msg-id 795093.1649774506@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
"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



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.
Next
From: Tom Lane
Date:
Subject: Re: BUG #17462: Invalid memory access in heapam_tuple_lock