Re: Distinct types - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Distinct types
Date
Msg-id 200811290026.13837.peter_e@gmx.net
Whole thread Raw
In response to Re: Distinct types  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Distinct types  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Friday 28 November 2008 18:49:17 Tom Lane wrote:
> > * Strong typing is preferable in complex applications to avoid errors
> > like sum(ordinal_column). Most developers use this all the time in their
> > 3GL code but cannot use it in SQL.
>
> The problem I see with distinct types is that the typing is *too*
> strong --- the datatype has in fact got no usable operations whatever.

You are supposed to define your own.  It's a new type after all.  You only 
borrow the representation from an existing one.

Random example, maybe not the best one: When you create an email type based on 
text, you don't really want to carry the || operator along, because email || 
email is not an email (usually).  The same applies to substring and pretty 
much everything else.  Domains are not the best solution if you want type 
safety.


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Fixing contrib/isn for float8-pass-by-value
Next
From: Tom Lane
Date:
Subject: Re: Distinct types