elein <elein@varlena.com> writes:
> So exactly what is the order of casts that produces
> different results with:
> 'x' || ' ' || 'x' and 'x' || ' '::char15 || 'x'
> Are operators being invoked both (text,text)?
The only relevant operator is "text || text" (there are also some ||
operators for arrays, bytea, and BIT, but these will all be discarded
as not the most plausible match). Therefore, in your first example the
unspecified literals will all be presumed to be text, so the space does
not get trimmed.
One of the things we could think about as a way to tweak the behavior is
creating "||" variants that are declared to accept char(n) on one or
both sides. These could actually use the same C implementation function
(textcat) of course. But declaring them that way would suppress the
invocation of rtrim() as char-to-text conversion.
However, if we did that then "||" would behave differently from other
operators on character strings, so it doesn't seem like a very
attractive option to me.
regards, tom lane