Re: Catalog domain not-null constraints - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Catalog domain not-null constraints
Date
Msg-id 804552.1711068412@sss.pgh.pa.us
Whole thread Raw
In response to Re: Catalog domain not-null constraints  (Vik Fearing <vik@postgresfriends.org>)
Responses Re: Catalog domain not-null constraints
List pgsql-hackers
Vik Fearing <vik@postgresfriends.org> writes:
> On 3/22/24 00:17, Tom Lane wrote:
>> Vik Fearing <vik@postgresfriends.org> writes:
>>> As also said somewhere in that thread, I think that <cast specification>
>>> short-cutting a NULL input value without considering the constraints of
>>> a domain is a bug that needs to be fixed in the standard.

>> I think it's probably intentional.  It certainly fits with the lack of
>> syntax for DOMAIN NOT NULL.  Also, it's been like that since SQL99;
>> do you think nobody's noticed it for 25 years?

> Haven't we (postgres) had bug reports of similar age?

Well, they've looked it at it since then.  SQL99 has

    c) If SV is the null value, then the result is the null value.

SQL:2008 and later have the text I quoted:

    c) If SV is the null value, then the result of CS is the null
    value and no further General Rules of this Sub-clause are
    applied.

I find it *extremely* hard to believe that they would have added
that explicit text without noticing exactly which operations they
were saying to skip.

> Anyway, I will bring this up with the committee and report back.  My 
> proposed solution will be for CAST to check domain constraints even if 
> the input is NULL.

Please do not claim that that is the position of the Postgres project.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Paul Jungwirth
Date:
Subject: Re: SQL:2011 application time
Next
From: Nathan Bossart
Date:
Subject: Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs