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

Re: Bug on CHARACTER(n) ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stefano Reksten <sreksten(at)sdb(dot)it>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug on CHARACTER(n) ?
Date: 2005-11-28 17:19:58
Message-ID: 12568.1133198398@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Stefano Reksten <sreksten(at)sdb(dot)it> writes:
> SELECT length(name), name from test;
>   length |    name
> --------+------------
>        4 | test

> Should not a char(10) insert 6 padding spaces?

It does, as you can see in the above output; but the padding spaces are
considered semantically insignificant and are therefore ignored by
length() and by concatenation.  If you think that trailing spaces are
meaningful data, then use varchar(n) or text.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Alvaro HerreraDate: 2005-11-28 17:24:05
Subject: Re: segfault of autovacuum process during restore - coredumps included
Previous:From: Pawel BernatDate: 2005-11-28 17:02:55
Subject: Re: Bug on CHARACTER(n) ?

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