Re: Prefered Types

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Prefered Types
Дата
Msg-id 9904.1304516978@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Prefered Types  (Jim Nasby <jim@nasby.net>)
Список pgsql-hackers
Jim Nasby <jim@nasby.net> writes:
> Which begs the question... why do we allow on assignment casting of a float to an int?

Because the SQL standard requires it.

In any case, the user's intent in such a case is perfectly clear.
The reasons for not allowing assignment casts to happen in expression
contexts are (1) it would often provide us with too many ways to resolve
an operator or function call, leading to "ambiguous operator" failures;
(2) it would be surprising for the parser to silently choose a cast that
causes information loss.  Neither of these arguments applies to "assign
this value to an integer column".

It's true that if you have exactly one function named f, and it takes an
int, then f(float) could be considered clear and unambiguous.  But
designing this behavior around only the easy cases is not going to work.
        regards, tom lane


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

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: Prefered Types
Следующее
От: Robert Haas
Дата:
Сообщение: Re: branching for 9.2devel