Re: Distinct types - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Distinct types
Date
Msg-id 1226044302.1432.107.camel@jdavis
Whole thread Raw
In response to Distinct types  (Peter Eisentraut <peter_e@gmx.net>)
List 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

pgsql-hackers by date:

Previous
From: "Brendan Jurd"
Date:
Subject: Re: Patch for ISO-8601-Interval Input and output.
Next
From: "Robert Haas"
Date:
Subject: Re: array_length()