moving char() to varchar()

From: Andrew Sullivan <andrew(at)libertyrms(dot)com>
To: PostgreSQL general list <pgsql-general(at)postgresql(dot)org>
Subject: moving char() to varchar()
Date: 2001-09-07 19:21:32
Message-ID: 20010907152132.B29953@mail.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

The developers of our application changed a number of fields from
char() to varchar() (which was a Good Thing, for reasons I won't bore
you with). Now, I thought I could just do a pg_dump -a on the
database, create the new schema, and load the old data into the new
schema, and the new varchar() columns would be trimmed. They're
not, however: they get blank-padded to the old length. Obviously,
the answer is to go through and trim() all the columns; not a
problem. But I have two questions.

1. I thought the SQL spec required varchar() not to pad. Is it
just that, because of the way pg_dump saved the char() data (as
blank-padded) that the varchar() field preserves the padded data?

2. I could _swear_ I did something very similar to this some
time ago (version 6.5.x? something like that?). Am I just imagining
things? (I'm perfectly prepared to accept that, by the way. My
memory is about as reliable these days as the DIMM I took out of my
PC last week. That's why I need a good DBMS like postgres!)

A
--
----
Andrew Sullivan 87 Mowat Avenue
Liberty RMS Toronto, Ontario Canada
<andrew(at)libertyrms(dot)com> M6K 3E3
+1 416 646 3304 x110

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas T. Thai 2001-09-07 19:46:35 Re: Idea: jobs.postgresql.org
Previous Message Peter Eisentraut 2001-09-07 19:11:56 Re: What Is The Firing Order?