Re: Implementing DB2's "distinct" types
От | Atri Sharma |
---|---|
Тема | Re: Implementing DB2's "distinct" types |
Дата | |
Msg-id | 5F6B5607-CA0B-43FE-BA07-83C46A11DE47@gmail.com обсуждение исходный текст |
Ответ на | Implementing DB2's "distinct" types (Thomas Kellerer <spam_eater@gmx.net>) |
Ответы |
Re: Implementing DB2's "distinct" types
|
Список | pgsql-general |
Sent from my iPad On 21-Apr-2013, at 16:47, Thomas Kellerer <spam_eater@gmx.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 theyare _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
В списке pgsql-general по дате отправления: