Re: constraints evaluate 'now' immediately - Mailing list pgsql-bugs

From Tom Lane
Subject Re: constraints evaluate 'now' immediately
Date
Msg-id 27347.971726763@sss.pgh.pa.us
Whole thread Raw
In response to constraints evaluate 'now' immediately  (pgsql-bugs@postgresql.org)
List pgsql-bugs
pgsql-bugs@postgresql.org writes:
> I would like a constraint stating that a column may not have a date in the future:
> CHECK(my_date <= 'now')
> but I think it stores the time of constraint creation.

Yes, because 'now' is evaluated when the constant is parsed.  Try
    CHECK(my_date <= now())
instead.

            regards, tom lane

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: constraints evaluate 'now' immediately
Next
From: Eivind Kvedalen
Date:
Subject: bug-report