Re: Prefered Types - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Prefered Types
Date
Msg-id 9904.1304516978@sss.pgh.pa.us
Whole thread Raw
In response to Re: Prefered Types  (Jim Nasby <jim@nasby.net>)
List 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 by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Prefered Types
Next
From: Robert Haas
Date:
Subject: Re: branching for 9.2devel