Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
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

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux