Re: Can't figure out how to use now() in default for tsrange column (PG 9.2)

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Chris Bartlett <c(dot)bartlett(at)paradise(dot)net(dot)nz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Can't figure out how to use now() in default for tsrange column (PG 9.2)
Date: 2012-07-16 11:41:39
Message-ID: CAF-3MvPByCKiA2hf+TBbBjnrRJ91wt5asAnVo=qz=KZGAj+Jpw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> BTW, that second value looks a whole lot like a poorly thought out
>> substitute for 'infinity' ...
>> regards, tom lane
>
> That's certainly an interesting comment and I'm open to suggestions! The
> original db has two columns (from_timestamp, to_timestamp). I don't go for
> NULL in the to_timestamp column. Alternatively, a timestamp very, very far
> in the future can throw off query planners.

Tom is telling you that there is a special "timestamp" 'infinity':

alter table the_table alter column the_column set default
tsrange(now()::timestamp without time zone, 'infinity'::timestamp
without time zone);

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nicolau Roca 2012-07-16 11:52:53 Replication terminated by primary server
Previous Message Chris Bartlett 2012-07-16 10:41:59 Re: Can't figure out how to use now() in default for tsrange column (PG 9.2)