Re: BUG #11875: char() not behaving as documented - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #11875: char() not behaving as documented
Date
Msg-id 15515.1415133369@sss.pgh.pa.us
Whole thread Raw
In response to BUG #11875: char() not behaving as documented  (b.wood@niwa.co.nz)
List pgsql-bugs
b.wood@niwa.co.nz writes:
> According to the docs
> http://www.postgresql.org/docs/9.3/static/datatype-character.html)(:
> " If the string to be stored is shorter than the declared length, values of
> type character will be space-padded; values of type character varying will
> simply store the shorter string."

Quite.

> Yet chars are not being padded

Yes they are.  You are neglecting the fact that a coercion from char to
varchar/text strips trailing blanks, so that a test like this:

> fish=# select var3||':' as var3, cha3||':' as char3 from test;

proves nothing at all about how many trailing spaces there were in
cha3.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Andres Freund
Date:
Subject: Re: [HACKERS] COPY TO returning empty result with parallel ALTER TABLE
Next
From: Tom Lane
Date:
Subject: Re: PostgreSQL 9.3 Segfault in "hstore_to_json" function