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