Re: unexpected check constraint violation - Mailing list pgsql-general

From Scott Marlowe
Subject Re: unexpected check constraint violation
Date
Msg-id dcc563d10903231401l32d5224buc150f26bb8595c86@mail.gmail.com
Whole thread Raw
In response to unexpected check constraint violation  (Jacek Becla <becla@slac.stanford.edu>)
List pgsql-general
On Mon, Mar 23, 2009 at 1:54 PM, Jacek Becla <becla@slac.stanford.edu> wrote:
> Hi,
>
> Can someone explain why postgres complains in this case:
>
> create table t(d real, check(d>=0.00603));
> insert into t values (0.00603);
>
> ERROR:  new row for relation "t" violates check constraint "t_d_check"

Without any casting, 0.00603 likely evaluates to a numeric.

select 0.00603::numeric > 0.00603::real;
 ?column?
----------
 t

So, this works:

 create table t(d real, check(d>=0.00603::real));
insert into t values (0.00603);
INSERT 0 1

pgsql-general by date:

Previous
From: Whit Armstrong
Date:
Subject: libpq -- reading a timestamp with time zone using binary format
Next
From: Marinos Yannikos
Date:
Subject: 1- and 2-dimensional indexes on same column: why is the 2d one preferred?