Skip site navigation (1) Skip section navigation (2)

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

From: <terry(at)ashtonwoodshomes(dot)com>
To: "'scott(dot)marlowe'" <scott(dot)marlowe(at)ihs(dot)com>,"'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'elein'" <elein(at)varlena(dot)com>,"'news(dot)postgresql(dot)org'" <jlim(at)natsoft(dot)com(dot)my>,<pgsql-sql(at)postgresql(dot)org>
Subject: Re: CHAR(n) always trims trailing spaces in 7.4
Date: 2004-02-18 00:23:44
Message-ID: 006f01c3f5b5$78932220$2766f30a@development.greatgulfhomes.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
> select 'x'||' '||'x'
>
> should produce xx, but it produces x x.
>

INCORRECT

This
select 'x'||' '::char ||'x'

Should produce xx

This
select 'x'||' '||'x'
is restateable as select 'x'|| ' '::text ||'x'

And the || operand for text is not dropping the extra spaces hence correctly
x x

Terry Fielder
Manager Software Development and Deployment
Great Gulf Homes / Ashton Woods Homes
terry(at)greatgulfhomes(dot)com
Fax: (416) 441-9085


> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org
> [mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of scott.marlowe
> Sent: Tuesday, February 17, 2004 7:07 PM
> To: Tom Lane
> Cc: elein; news.postgresql.org; pgsql-sql(at)postgresql(dot)org
> Subject: Re: [SQL] CHAR(n) always trims trailing spaces in 7.4
>
>
> On Tue, 17 Feb 2004, Tom Lane wrote:
>
> > elein <elein(at)varlena(dot)com> writes:
> > > 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)
> >
> > Still does, but then the spaces go away again when the
> value goes into
> > the concatenation, because concatenation is a text operator.
>
> But then this:
>
> select 'x'||' '||'x'
>
> should produce xx, but it produces x x.
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>


In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2004-02-18 00:25:47
Subject: Re: CHAR(n) always trims trailing spaces in 7.4
Previous:From: scott.marloweDate: 2004-02-18 00:07:24
Subject: Re: CHAR(n) always trims trailing spaces in 7.4

pgsql-sql by date

Next:From: Tom LaneDate: 2004-02-18 00:25:47
Subject: Re: CHAR(n) always trims trailing spaces in 7.4
Previous:From: scott.marloweDate: 2004-02-18 00:07:24
Subject: Re: CHAR(n) always trims trailing spaces in 7.4

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group