Re: round() function wrong?

Поиск
Список
Период
Сортировка
От scott.marlowe
Тема Re: round() function wrong?
Дата
Msg-id Pine.LNX.4.33.0310241422440.25577-100000@css120.ihs.com
обсуждение исходный текст
Ответ на Re: round() function wrong?  (Michael Brusser <michael@synchronicity.com>)
Ответы Re: round() function wrong?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Fri, 24 Oct 2003, Michael Brusser wrote:

> But this seems to work correctly on 7.3.2 and 7.3.4:
> psql -c "select round (2.5)"
> Password: 
>  round 
> -------
>      3
> (1 row)
> 
> =============
> > 
> > I just tried that on my 7.2.4 and 7.4 beta 4 machines and I get 2 for 
> > round(2.5)

Ackkk.  I accidentally tested it on my 7.3.4 box, not my 7.4 beta 4 box. 
but the output is the same.  The original, I believe, had '' marks in it.

Anyway, it seems to matter about the ''s in 7.3.x:


In pgsql 7.2:

select round(2.5::float);round
-------    2
(1 row)

select round(2.5::numeric);round
-------    3
(1 row)

select round(2.5);  <-- would appear to be coerced to float here)round
-------    2
(1 row)

select round('2.5');
ERROR:  Function 'round(unknown)' does not exist       Unable to identify a function that satisfies the given argument

types       You may need to add explicit typecasts


pgsql 7.3.4:


select round(2.5::float);round
-------    2
(1 row)

select round(2.5::numeric);round
-------    3
(1 row)

select round(2.5);  <-- would appear to be coerced to numericround
-------    3
(1 row)

select round('2.5');round
-------    2
(1 row)

pgsql 7.4 beta5: behaves the same as 7.3.4

So it would appear to be that the automatic assumptions about what is 
float and what is numeric changed from 7.2 to 7.3, i.e. it's assumed that 
numeric is the input type.

But I'm just guessing here.





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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Call for port reports
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Call for port reports