Kostin:
On Wed, Sep 6, 2017 at 3:21 PM, <kostin.artem@gmail.com> wrote:
> These two commands produce different results with similar types
> select substring(cast(' 2345 ' as character(16)), 1, 7) || '?',
> substring(cast(' 2345 ' as varchar(16)), 1, 7) || '?';
>
> " 2345?";" 2345 ?"
>
> Should it work in this way or not?
If you are not sure whether something is a bug, you should try asking
in the general list, to avoid noise.
Anyway, you may notice char() discards trailing blanks, varchar does not:
n=> select cast(' 2345 ' as character(16)) || '?';?column?
---------- 2345?
(1 row)
Plain char is STORED space padded and TRUNCATED if too long ( standard
required IIRC ), and trailing spaces are disregarded in many places,
such as when concatenating.
Francisco Olarte.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs