Re: Altering a CHAR(4) column CHAR(5) changing pg_attribute

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Denis Gasparin <denis(at)edistar(dot)com>, Postgresql General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Altering a CHAR(4) column CHAR(5) changing pg_attribute
Date: 2002-03-26 17:29:07
Message-ID: 29225.1017163747@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> If you were using varchar, this would be fine. With char, you have
> issues with the padding spaces if you ever convert them to text
> (for example using lower or upper).

But you could do
update foo set mycol = mycol || '';
after tweaking the atttypmod as Stephan illustrates. That should force
all the values to the correct length. (The dummy concatenation is just
to prevent the system from optimizing away the length coercion step.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message postgresql 2002-03-26 17:30:08 Re: Performance in subconsult
Previous Message Stephan Szabo 2002-03-26 16:52:06 Re: Altering a CHAR(4) column CHAR(5) changing pg_attribute