Re: Domains versus polymorphic functions, redux

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: "Noah Misch" <noah(at)leadboat(dot)com>,<lr(at)pcorp(dot)us>, <pgsql-hackers(at)postgresql(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Domains versus polymorphic functions, redux
Date: 2011-06-03 18:53:27
Message-ID: 4DE8E757020000250003E104@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> The real crux of the issue here is: under what circumstances
> should we look through the domain wrapper around an underlying
> type, and under what circumstances should we refrain from doing
> so?

I don't know if this is the intent of domains in the SQL standard,
but I find them useful to "extend" other types (in the
object-oriented sense). "CaseNoT" *is a* varchar(14), but not every
varchar(14) is a "CaseNoT". In my view, behaviors should be
determined based on that concept.

In the long run, it would be fabulous if a domain could extend
another domain -- or event better, multiple other domains with the
same base type. DOT hair color code and DOT eye color code domains
might both extend a DOT color codes domain.

Another long-range nicety would be something which I have seen in
some other databases, and which is consistent with the inheritance
theme, is that you can't compare or assign dissimilar domains -- an
error is thrown. So if you try to join from the eye color column in
a person table to the key of a hair color table, you get an error
unless you explicitly cast one or both of them to the common type.

I know that doesn't directly answer the question, but I think it
provides some framework for making choices....

-Kevin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-06-03 18:58:44 Re: Domains versus polymorphic functions, redux
Previous Message Peter Eisentraut 2011-06-03 18:51:45 permissions of external PID file