Re: Weird type selection choice

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Weird type selection choice
Дата
Msg-id 21234.1194364873@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Weird type selection choice  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: Weird type selection choice  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> It apparently casts the 1 to double precision to pick the variant
> trunc(dp)=>dp instead of trunc(numeric)=>numeric.  I was under the impression
> that we didn't want to cast integers to float types implicitly because this
> loses information.  Clearly, the numeric variant should be preferred anyway.

There's nothing "clear" about that at all.  float8 is the preferred type
in the numeric category, so preferring trunc(dp) over trunc(numeric) is
exactly what I'd expect to happen.  This is not something that can be
readily changed, because if we made numeric the preferred type we'd be
violating the SQL spec.  The result of, for example, float8 + numeric
has to be float8:
        2) If the declared type of either operand of a dyadic arithmetic           operator is approximate numeric,
thenthe declared type of the           result is approximate numeric.
 
        regards, tom lane


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Weird type selection choice
Следующее
От: "Gevik Babakhani"
Дата:
Сообщение: Opinion / advice needed for TODO: function params ref by name