From: | Atri Sharma <atri(dot)jiit(at)gmail(dot)com> |
---|---|
To: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Implementing DB2's "distinct" types |
Date: | 2013-04-21 11:37:48 |
Message-ID: | 5F6B5607-CA0B-43FE-BA07-83C46A11DE47@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Sent from my iPad
On 21-Apr-2013, at 16:47, Thomas Kellerer <spam_eater(at)gmx(dot)net> wrote:
> Hi,
>
> I recently stumbled upon a really cool feature in DB2: distinct types.
>
> DB2 lets you define your own types (just as Postgres) but with the added benefit that you can mark them such that they are _not_ comparable, e.g. to avoid comparing "apples to oranges".
>
> Take the following example:
>
> create type sno as varchar(50)
> with comparisons;
> create type pno as varchar(50)
> with comparisons;
>
> create table s
> (
> sno sno not null primary key,
> .... other columns
> );
>
> create table p
> (
> pno pno not null primary key,
> .... other columns
> );
>
> The following query will be rejected because sno and pno are not comparable (even though both are varchar columns):
>
> select *
> from p
> join s on s.sno = p.pno;
>
> I wonder if a similar behaviour can be achieved with Postgres' types as well.
>
> As a type definition in Postgres can also include comparison functions, I have the feeling that this should be possible, but I don't have an idea on how to start to be honest.
>
> Any ideas?
>
> Regards
> Thomas
>
>
>
>
>
>
Please mark this to pgsql-hackers, where you might get much better constructive feedback.
It does sound nice.
Atri
From | Date | Subject | |
---|---|---|---|
Next Message | Stefan Kaltenbrunner | 2013-04-21 12:21:55 | Re: Roadmap for Postgres on AIX |
Previous Message | Thomas Kellerer | 2013-04-21 11:17:59 | Implementing DB2's "distinct" types |