Re: [BUGS] BUG #5053: domain constraints still leak

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: sam(at)samason(dot)me(dot)uk (Sam Mason), pgsql-hackers(at)postgresql(dot)org
Subject: Re: [BUGS] BUG #5053: domain constraints still leak
Date: 2009-09-15 13:54:18
Message-ID: 87r5u85n5h.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

>>>>> "Sam" == Sam Mason <sam(at)samason(dot)me(dot)uk> writes:

>> But there's a kicker: in Subclause 6.12, <cast specification>, in the
>> General Rules is:
>>
>> a) If the <cast operand> specifies NULL, then the result of CS is
>> the null value and no further General Rules of this Subclause
>> are applied.
>>
>> That "no further General Rules" clause implies (assuming it's not a
>> blatant mistake in the spec) that this rule is therefore skipped in
>> the case of nulls:

Sam> I think the NOT NULL constraint is a PG specific constraint, I
Sam> can't see how it's allowed in the spec.

That's a good point; it doesn't seem to be.

But the spec _does_ appear to allow CHECK(VALUE IS NOT NULL) as a
domain constraint (in general the spec defines NOT NULL constraints
this way), and the wording from 6.12 implies that that check is still
skipped in the case of NULLs (so that constraint would stop you
inserting a null into a table column (I think), but not from casting a
null value to the domain type).

Sam> The NOT NULL constraint feels wrong as well, what are the
Sam> semantics of:

Sam> CREATE DOMAIN d AS INTEGER NOT NULL;
Sam> SELECT a.n AS aa, b.n AS bb
Sam> FROM (VALUES (CAST(1 AS d)),(2)) a(n)
Sam> LEFT JOIN (VALUES (CAST(1 AS d))) b(n) ON a.n = b.n;

Sam> in the presence of it? I'm expecting aa and bb both to come out
Sam> as domain "d", but this shouldn't work with what you're saying
Sam> the current semantics should be.

I think that's just another example of Tom's initial comment about how
broken domain "not null" constraints are currently.

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2009-09-15 14:05:23 Re: [BUGS] BUG #5053: domain constraints still leak
Previous Message Sam Mason 2009-09-15 10:44:03 Re: [BUGS] BUG #5053: domain constraints still leak

Browse pgsql-hackers by date

  From Date Subject
Next Message Brendan Jurd 2009-09-15 13:54:51 Re: CommitFest 2009-09: Now In Progress
Previous Message Robert Haas 2009-09-15 13:48:51 Re: CommitFest 2009-09: Now In Progress