pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.
3+ messages / 3 participants
[nested] [flat]

* BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.
@ 2022-04-12 12:41 PG Bug reporting form <noreply@postgresql.org>
  2022-04-12 14:27 ` 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>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2022-04-12 12:41 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: dafoer_x@163.com

The following bug has been logged on the website:

Bug reference:      17464
Logged by:          Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot
be intercepted.
Email address:      dafoer_x@163.com
PostgreSQL version: 13.2
Operating system:   centos7.6 x86
Description:        

Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot
be intercepted.
Because texteq cannot accept null input parameters,
op->d.domainCheck.checknull is set to the wrong value .

detail:
postgres=# call f3_basic('男');
NOTICE:  a_xb = 男
CALL
postgres=# call  f3_basic('她');
NOTICE:  a_xb = 她
CALL


eg.
drop domain xb;
CREATE DOMAIN xb AS TEXT CHECK
(
   VALUE = '男'
   OR VALUE ='女'
   OR VALUE = null
 );
drop procedure if exists f3_basic(a_xb xb);
CREATE OR REPLACE procedure f3_basic (a_xb xb)  AS
$$
BEGIN
 RAISE NOTICE 'a_xb = %',a_xb;
END;
$$
LANGUAGE PLPGSQL;
-- success
call f3_basic('男');
-- expected error
call  f3_basic('她');
drop procedure if exists f3_basic(a_xb xb);
drop domain xb;



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.
  2022-04-12 12:41 BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted. PG Bug reporting form <noreply@postgresql.org>
@ 2022-04-12 14:27 ` David G. Johnston <david.g.johnston@gmail.com>
  2022-04-12 14:41   ` Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: David G. Johnston @ 2022-04-12 14:27 UTC (permalink / raw)
  To: dafoer_x@163.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Tue, Apr 12, 2022 at 7:16 AM PG Bug reporting form <
noreply@postgresql.org> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      17464
> Logged by:          Domain type. If the value field(CREATE DOMAIN) is set
> to null, errors cannot
> be intercepted.
> Email address:      dafoer_x@163.com
> PostgreSQL version: 13.2
> Operating system:   centos7.6 x86
> Description:
>
> Domain type. If the value field(CREATE DOMAIN) is set to null, errors
> cannot
> be intercepted.
> Because texteq cannot accept null input parameters,
> op->d.domainCheck.checknull is set to the wrong value .
>

I'm not really following, and don't have time to investigate this right
now, but:

CREATE DOMAIN xb AS TEXT CHECK
> (
>    VALUE = '男'
>    OR VALUE ='女'
>    OR VALUE = null
>  );
>
>
"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.

David J.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted.
  2022-04-12 12:41 BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted. PG Bug reporting form <noreply@postgresql.org>
  2022-04-12 14:27 ` 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>
@ 2022-04-12 14:41   ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2022-04-12 14:41 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: dafoer_x@163.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

"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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-04-12 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 12:41 BUG #17464: Domain type. If the value field(CREATE DOMAIN) is set to null, errors cannot be intercepted. PG Bug reporting form <noreply@postgresql.org>
2022-04-12 14:27 ` David G. Johnston <david.g.johnston@gmail.com>
2022-04-12 14:41   ` Tom Lane <tgl@sss.pgh.pa.us>

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