Tom Lane <tgl@sss.pgh.pa.us> writes:
> Right, because assigning to a table column is an "assignment" cast ---
> which has more liberal rules, because either you can coerce the value
> to the table column's type or you're going to fail anyway. So the
> system will take the integer literal and try to downcast to smallint,
> and if that doesn't work then the query was doomed anyhow.
This one sank in last night when I re-read the docs for CREATE CAST.
> Coercion of a value to match a function argument is a different matter;
> the system will not choose a coercion that is "surprising" in any way
> or has the potential to fail due to issues such as range limitations.
> The reason for the difference in behavior is probably not very obvious
> when you have only one possible function to match, but we need this
> restriction in order for things to behave sanely with overloaded
> functions (or operators). The text in chapter 10 expands on that a
> bit.
This is exactly what was confusing us; we aren't using function overloading so at the time it seemed like it should
justwork. I think I finally understand it again re-reading chapter 10 again.
Thanks,
Matt