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

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <pgsql-hackers(at)postgresql(dot)org>,"Sam Mason" <sam(at)samason(dot)me(dot)uk>
Subject: Re: [BUGS] BUG #5053: domain constraints still leak
Date: 2009-09-15 20:20:51
Message-ID: 4AAFB0D3020000250002B00B@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Since our shop seems to use domains more than most, I figured I
should comment on this thread.

>Sam Mason <sam(at)samason(dot)me(dot)uk> wrote:
>> On Tue, Sep 15, 2009 at 02:54:18PM +0100, Andrew Gierth wrote:

>> 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).
>
> Explicitly ignoring NULL values in CAST expressions seems like a
> good feature as well.

OK by me.

> Although it gives me the feeling that domains are more
> and more like a mis-designed feature.

They have their place, for when you don't really need a new type,
but you want to show that multiple columns contain data from the
same set. My rule of thumb is this -- if it would make sense for
two columns to be compared for equality, there's a very good chance
they belong in the same domain; if not, they probably don't. Using
them helps to document complex databases and helps with portability,
quite aside from the issue of constraints.

> Hum, given that it's just sugar for more general constraints I'm
> not sure if it's the not null constraints that are broken or just
> the current interpretation of them. They would do the "right
> thing" if they were only checked in a limited number of places
> that the user was aware of, which the spec seems to imply is when
> the user explicitly asks for a CAST to be performed or when
> writing into the table.

If that's what the spec says, then +1 from me. The change won't
cause problems here.

-Kevin

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Simon Riggs 2009-09-15 20:41:17 Re: GIN needs tonic
Previous Message Tom Lane 2009-09-15 19:34:55 Re: GIN needs tonic

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-09-15 20:58:19 Re: dropping partitions and concurrent reads
Previous Message David E. Wheeler 2009-09-15 20:16:38 Re: Timestamp to time_t