bigint datatype accepting floating numbers

Поиск
Список
Период
Сортировка
От Chris
Тема bigint datatype accepting floating numbers
Дата
Msg-id am1ep8$1nkh$1@news.hub.org
обсуждение исходный текст
Ответы Re: bigint datatype accepting floating numbers  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi all,

Sorry if this comes through multiple times.

Just wondering if anyone can explain why this is happening. I thought
int2, int4, int8 all accepted integers only (according to the way the
docs read at least).


test=# SELECT version();
                                  version
------------------------------------------------------------------
    PostgreSQL 7.3b1 on i586-pc-linux-gnu, compiled by GCC 2.95.3
(1 row)


test=# create table testint(smallnum int2, num int4, bignum int8);
CREATE TABLE

test=# insert into testint (smallnum) values (123.7);
ERROR:  column "smallnum" is of type 'smallint' but expression is of
type 'double precision'
             You will need to rewrite or cast the expression

test=# insert into testint (num) values (123.7);
ERROR:  column "num" is of type 'integer' but expression is of type
'double precision'
             You will need to rewrite or cast the expression

test=# insert into testint (bignum) values (123.7);
INSERT 17320 1

It seems to round the number too:

test=# SELECT * from testint;
      smallnum | num | bignum
----------+-----+--------
               |     |    124
(1 row)





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

Предыдущее
От: Justin Clift
Дата:
Сообщение: Re: Anyone remember the name of the PostgreSQL GUI installer
Следующее
От: "Shridhar Daithankar"
Дата:
Сообщение: Re: Physical sites handling large data