Re: char(n) to varchar or text conversion should strip trailing spaces - Mailing list pgsql-hackers

From Tom Lane
Subject Re: char(n) to varchar or text conversion should strip trailing spaces
Date
Msg-id 28911.1037630132@sss.pgh.pa.us
Whole thread Raw
In response to Re: char(n) to varchar or text conversion should strip trailing spaces  ("Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>)
Responses Re: char(n) to varchar or text conversion should strip  (Peter Eisentraut <peter_e@gmx.net>)
Re: char(n) to varchar or text conversion should strip trailing spaces  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at> writes:
> One alternate possible approach would maybe be to change the on-disk
> representation to really be binary compatible and change the input 
> output and operator functions ?

Hmm ... now that's an interesting thought.  So the input converter would
actively strip trailing blanks, output would add them back, and only in
a few char(n)-specific functions would we need to pretend they are there.

This would mean that char(n)-to-text is binary compatible but the
reverse direction is not (it must strip trailing blanks) --- but that
coercion could be folded into the existing length-limit checker for
char(n) columns.

> IIRC fixed width optimizations do not gain as 
> much as in earlier versions anyway.

There are no fixed-width optimizations for char(n) at all, now that we
have multibyte enabled all the time.

Seems like a great idea to me.
        regards, tom lane


pgsql-hackers by date:

Previous
From: s0lao@netscape.net (S. L.)
Date:
Subject: Re: [CYGWIN] ipc-daemon
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] DECLARE CURSOR