Re: Domains versus polymorphic functions, redux
Kevin Grittner <kevin.grittner@wicourts.gov>
From: "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
To: "Robert Haas" <robertmhaas@gmail.com>, "David E. Wheeler" <david@kineticode.com>
Cc: "Noah Misch" <noah@leadboat.com>,<lr@pcorp.us>, <pgsql-hackers@postgresql.org>, "Tom Lane" <tgl@sss.pgh.pa.us>
Date: 2011-06-03T18:53:27Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.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