tip to workaround trailing spaces removal on char to varchar conversion

From: vodevsh(at)gmail(dot)com
To: pgsql-docs(at)postgresql(dot)org
Subject: tip to workaround trailing spaces removal on char to varchar conversion
Date: 2017-09-20 12:46:26
Message-ID: 20170920124626.17363.48015@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.6/static/datatype-character.html
Description:

removing trailing spaces on (implicit) cast from char to text can be
painful, and always surprising as shown in example with
SELECT 'a '::CHAR(2) collate "C" < E'a\n'::CHAR(2)

would it be worth mentioning a tip, that this behaviour can be monkey hacked
by concat(str "any" function that accepts char and returns text, thus
respecting the spaces, eg SELECT concat('a '::CHAR(2) collate "C") <
E'a\n'::CHAR(2) will return false as expected...

Browse pgsql-docs by date

  From Date Subject
Next Message Alexander Lakhin 2017-09-20 13:00:00 Re: Docbook 5.x
Previous Message Peter Eisentraut 2017-09-19 20:05:35 Re: Docbook 5.x