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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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-15 15:19:59
Message-ID: 29175.1342365599@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris Bartlett <c(dot)bartlett(at)paradise(dot)net(dot)nz> writes:
> I'm trying to set [now(), 2049-12-31 00:00:00) as the default for a
> tsrange column (Postgres 9.2), but can't figure out how to do it. I'm
> either getting syntax errors or now() is being evaluated, so that the
> default becomes something like [2012-07-14 14:04:35, 2049-12-31
> 00:00:00), which is not what I want. Can anyone point me in the right
> direction, please?

I think you'd need to use the constructor function, ie

default tsrange(now(), '2049-12-31 00:00:00')

BTW, that second value looks a whole lot like a poorly thought out
substitute for 'infinity' ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bartosz Dmytrak 2012-07-15 18:54:53 Re: PostgreSQL limitations question
Previous Message Chris Bartlett 2012-07-15 10:25:43 Can't figure out how to use now() in default for tsrange column (PG 9.2)