Re: moving char() to varchar() - Mailing list pgsql-general

From Tom Lane
Subject Re: moving char() to varchar()
Date
Msg-id 4422.999895034@sss.pgh.pa.us
Whole thread Raw
In response to moving char() to varchar()  (Andrew Sullivan <andrew@libertyrms.com>)
Responses Re: moving char() to varchar()
List pgsql-general
Andrew Sullivan <andrew@libertyrms.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: What Is The Firing Order?
Next
From: David Ford
Date:
Subject: Problem w/ dumping huge table and no disk space