Re: CHECK constraint fails when it's not supposed to - Mailing list pgsql-general

From Tom Lane
Subject Re: CHECK constraint fails when it's not supposed to
Date
Msg-id 19212.1249412352@sss.pgh.pa.us
Whole thread Raw
In response to CHECK constraint fails when it's not supposed to  (Richard Yen <richyen3@gmail.com>)
List pgsql-general
Richard Yen <richyen3@gmail.com> writes:
> When I run my update, it fails:
>> tii=# begin; update only "public"."m_class" set date_end='2009-09-03
>> 05:38:24.030331-07',term_length='177 days 17:59:09.868431' where
>> id='2652020';
>> BEGIN
>> ERROR:  new row for relation "m_class" violates check constraint
>> "end_within_term_length"
>> tii=# rollback;

Hmm, I get this:

regression=# select '2009-03-09 11:39:14.1619-07'::timestamptz + '177 days 17:59:09.868431'::interval;
           ?column?
-------------------------------
 2009-09-03 05:38:24.030331-07
(1 row)

which is apparently exactly the same as your date_end value, but I bet
it's not quite the same after allowing for floating-point roundoff error.
If this database wasn't built with the exact-integer-timestamps option
then you can't assume that timestamp calculations are exact to the
microsecond.

            regards, tom lane

pgsql-general by date:

Previous
From: Frank Heikens
Date:
Subject: Re: Error when assigning default value for function parameter
Next
From: Guy Rouillier
Date:
Subject: Re: Does derby have an embedded Mode like Derby ?