From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Distinct types |
Date: | 2008-11-07 07:51:42 |
Message-ID: | 1226044302.1432.107.camel@jdavis |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 2008-10-31 at 16:03 +0200, Peter Eisentraut wrote:
> Here is an implementation of distinct types, known from SQL99 and
> beyond. They are like domains, except that they don't have defaults or
> constraints and they do not allow implicit casting to their base type.
> The latter aspect is what makes them distinct types. They are useful to
> create more type-safe database schemas, to prevent using generic types
> such as text or int for everything and then mixing them in inappropriate
> ways. This is something domains are not useful for. Much of the
> internals are shared with domains nevertheless. The difference is
> really only the casting behavior.
>
> To create a distinct type, just run
>
> CREATE TYPE mystring AS text;
>
It needs documentation, and I included a quick patch for that (if that's
helpful).
It builds fine for me and appears to do everything as advertised.
I skimmed the code and the relevant parts of the SQL standard, but it
may need further review by someone who knows the type system and the SQL
standard better than I.
Regards,
Jeff Davis
Attachment | Content-Type | Size |
---|---|---|
distinct_types_doc.diff | text/x-patch | 2.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2008-11-07 07:54:51 | Re: Final /contrib cleanup -- yes/no? |
Previous Message | Jaime Casanova | 2008-11-07 07:08:34 | Re: regression in analyze |