Re: unexpected check constraint violation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: Jacek Becla <becla(at)slac(dot)stanford(dot)edu>, ries van Twisk <pg(at)rvt(dot)dds(dot)nl>, pgsql-general(at)postgresql(dot)org
Subject: Re: unexpected check constraint violation
Date: 2009-03-23 23:07:50
Message-ID: 4597.1237849670@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> writes:
> You can either cast the check constraint, or change the field type to
> match double precision.

The short answer here is that 0.00603::double precision and
0.00603::real are unlikely to be exactly the same value, and
which one is greater is a matter of which direction the real
got rounded off in. On my machine the former is a bit larger:

regression=# select 0.00603::double precision - 0.00603::real;
?column?
----------------------
1.85072421797494e-10
(1 row)

but on another platform it could be the other way around.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-03-23 23:15:33 Re: libpq -- reading a timestamp with time zone using binary format
Previous Message Ivan Sergio Borgonovo 2009-03-23 23:00:50 Re: text column constraint, newbie question