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