Re: Is this a bug? Insert float into int column inserts rounded value instead of error.

Поиск
Список
Период
Сортировка
От Andrew Sullivan
Тема Re: Is this a bug? Insert float into int column inserts rounded value instead of error.
Дата
Msg-id 20070827212031.GB30834@phlogiston.dyndns.org
обсуждение исходный текст
Ответ на Is this a bug? Insert float into int column inserts rounded value instead of error.  (Matthew Schumacher <matt.s@aptalaska.net>)
Список pgsql-general
On Mon, Aug 27, 2007 at 12:48:34PM -0800, Matthew Schumacher wrote:
> When inserting a float such as 4.12322345 into a int column postgres
> inserts 4 instead of returning an error telling you that your value
> won't fit.  I would much rather have the error and check for it since I
> can be sure I'll get 4.12322345 back out if I didn't get an error on insert.

If you quote it, it works.  That is:

testing=# SELECT 4.123123123::int;
 int4
------
    4
(1 row)

testing=# SELECT '4.123123123'::int;
ERROR:  invalid input syntax for integer: "4.123123123"

A

--
Andrew Sullivan  | ajs@crankycanuck.ca
I remember when computers were frustrating because they *did* exactly what
you told them to.  That actually seems sort of quaint now.
        --J.D. Baldwin

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Is this a bug? Insert float into int column inserts rounded value instead of error.
Следующее
От: Erik Jones
Дата:
Сообщение: Re: Tables dissapearing