The following is with regard to PostgresQL 9.1 :
I am using the right() and left() string functions to fix a few instances where data was input into my database being “off by one” .. so I’m doing something along the lines of right(field1,1)||left(field2,-1
) to get correct values and such. In the process, I encountered an unexpected result on a char(2) column.
If I do SELECT RIGHT('A ',1)
it gives me the expected ' '
returned.
However, if I do SELECT RIGHT('A '::CHAR(2),1)
it gives me 'A'
.
Why is it doing this? Is it a bug? I tried SELECT RIGHT('A '::CHAR(3),1)
and it also gives 'A'
as a result.