From: | Scott Bailey <artacus(at)comcast(dot)net> |
---|---|
To: | |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: composite type and domain |
Date: | 2009-05-27 17:38:04 |
Message-ID: | 4A1D7A7C.8060608@comcast.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Scott Bailey wrote:
> Grzegorz Jaśkiewicz wrote:
>> Why is it not possible to create domain on composite type ?
>>
>> Consider the example, I got (a bytea, b timestamp, c timestamp). Where
>> b < c always, and both b and c have some default value, a can stay
>> null.
>> Now, I don't want to go berserk, and create aditional table for that,
>> because type is shared between two tables. But it would be nice, to be
>> able to create domain based on that type.
>> Any reasons I can't , or is it just something I do wrong?
>>
>> That's on 8.3/8.4
>>
>
> I think Postgres' type system is as good any and better than most...
> even if it doesn't do what you are asking. They ALL have their problems.
>
> What I do is handle it in the constructors. So if someone passes b > c
> it swaps them. It doesn't help for casts, so I'm careful to always use
> the constructors.
>
> I wrote a couple articles about doing this in Postgres and Oracle on my
> blog.
>
> http://scottrbailey.wordpress.com/2009/05/19/timespan-postgresql/
>
> Scott
I was also thinking that if you wanted more of the domain behavior; your
constructors could throw an exception rather than silently swapping b
and c, as I chose to do.
Scott
From | Date | Subject | |
---|---|---|---|
Next Message | Alan McKay | 2009-05-27 17:57:08 | Postgres Clustering |
Previous Message | Brad Nicholson | 2009-05-27 16:38:04 | Re: Bloated Table |