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