Re: CHAR(n) always trims trailing spaces in 7.4

From: elein <elein(at)varlena(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "news(dot)postgresql(dot)org" <jlim(at)natsoft(dot)com(dot)my>, pgsql-sql(at)postgresql(dot)org, elein <elein(at)varlena(dot)com>
Subject: Re: CHAR(n) always trims trailing spaces in 7.4
Date: 2004-02-17 23:17:28
Message-ID: 20040217151728.E25537@cookie.varlena.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

This is an example of the problem. It used to expand
the middle thing to 15.

elein=# select 'x' || ' '::char(15) || 'x';
?column?
----------
xx
(1 row)

On Tue, Feb 17, 2004 at 06:10:56PM -0500, Tom Lane wrote:
> "news.postgresql.org" <jlim(at)natsoft(dot)com(dot)my> writes:
> > I just discovered the following change to CHAR(n) (taken from varlena.com,
> > general bits, issue 62).
>
> The description you quote doesn't appear to have much of anything to do
> with the actual behavior of 7.4.
>
> 7.4 will trim trailing spaces when converting char(n) to varchar or
> text, but the example query does not do that. It just coerces query
> output columns to char(n), and that works the same as it did before.
> For instance
>
> regression=# select 'zit'::char(77);
> bpchar
> -------------------------------------------------------------------------------
> zit
> (1 row)
>
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-02-17 23:40:49 Re: CHAR(n) always trims trailing spaces in 7.4
Previous Message Tom Lane 2004-02-17 23:10:56 Re: CHAR(n) always trims trailing spaces in 7.4

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-02-17 23:33:54 Re: Return relation table data in a single value CSV
Previous Message Tom Lane 2004-02-17 23:10:56 Re: CHAR(n) always trims trailing spaces in 7.4