Skip site navigation (1) Skip section navigation (2)

Distinct types

From: Peter Eisentraut <Peter(dot)Eisentraut(at)Sun(dot)COM>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Distinct types
Date: 2008-10-31 12:37:28
Message-ID: 490AFC08.8040500@Sun.COM (view raw or whole thread)
Lists: pgsql-hackers
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;

Attachment: distinct-types.diff
Description: text/plain (20.4 KB)


pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2008-10-31 13:15:35
Subject: Re: Synchronous replication patch v1
Previous:From: Sam MasonDate: 2008-10-31 12:19:54
Subject: Re: array_agg and array_accum (patch)

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group