Is this a bug? Insert float into int column inserts rounded value instead of error.
От | Matthew Schumacher |
---|---|
Тема | Is this a bug? Insert float into int column inserts rounded value instead of error. |
Дата | |
Msg-id | 46D338A2.8010905@aptalaska.net обсуждение исходный текст |
Ответы |
Re: Is this a bug? Insert float into int column inserts rounded value instead of error.
Re: Is this a bug? Insert float into int column inserts rounded value instead of error. |
Список | pgsql-general |
List, One of the reasons why I use postgres is because you can insert data and it will work or give you an error instead of converting, truncating, etc... well I found a place where postgres makes an erroneous assumption and I'm not sure this is by design. 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. Is this by design? If so I think it should be changed so that postgres will always return your data exactly as you entered it if there isn't an error on insert. template1=# create table test (number int); CREATE TABLE template1=# insert into test (number) values (4.123123123); INSERT 0 1 template1=# select * from test; number -------- 4 (1 row) Thanks, schu
В списке pgsql-general по дате отправления: