Re: moving char() to varchar()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Sullivan <andrew(at)libertyrms(dot)com>
Cc: PostgreSQL general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: moving char() to varchar()
Date: 2001-09-07 20:37:14
Message-ID: 4422.999895034@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrew Sullivan <andrew(at)libertyrms(dot)com> writes:
> 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?

Right. Trailing blanks in the presented data *should* be preserved
by varchar; they're valid data, not pad, as far as the DB knows.

You could possibly make an argument that trailing blanks in a char()
column (which ARE known to be padding) should be stripped during dumping,
primarily for convenience in reloading into varchar columns. But this
seems a tad weird and unexpected to me. An explicit trim() operation
sounds like a better idea.

> 2. I could _swear_ I did something very similar to this some
> time ago (version 6.5.x? something like that?).

Could be. I think we've tweaked the behavior a few times to get closer
to the SQL92 spec.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Ford 2001-09-07 20:52:34 Problem w/ dumping huge table and no disk space
Previous Message Brook Milligan 2001-09-07 20:22:29 Re: [ANNOUNCE] Great Bridge ceases operations