Re: Distinct types

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: Distinct types
Date: 2008-11-28 22:26:13
Message-ID: 200811290026.13837.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-11-28 22:35:08 Re: Distinct types
Previous Message Peter Eisentraut 2008-11-28 22:22:29 Re: Fixing contrib/isn for float8-pass-by-value