From: | "Zeugswetter Andreas SB SD" <ZeugswetterA(at)spardat(dot)at> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | Re: char(n) to varchar or text conversion should strip trailing spaces |
Date: | 2002-11-18 10:42:07 |
Message-ID: | 46C15C39FEB2C44BA555E356FBCD6FA4961EF9@m0114.s-mxs.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> I've gotten really tired of explaining to newbies why stuff involving
> char(n) fields doesn't work like they expect. Our current behavior is
> not valid per SQL92 anyway, I believe.
>
> I think there is a pretty simple solution now that we have pg_cast:
> we could stop treating char(n) as binary-equivalent to varchar/text,
> and instead define it as requiring a runtime conversion (which would
> be essentially the rtrim() function). The cast in the other direction
> would be assignment-only, so that any expression that involves mixed
> char(n) and varchar/text operations would be evaluated in varchar
> rules after stripping char's insignificant trailing blanks.
>
> If we did this, then operations like
> WHERE UPPER(charcolumn) = 'FOO'
> would work as a newbie expects. I believe that we'd come a lot closer
> to spec compliance on the behavior of char(n), too.
I am all for it. That would much more closely match what I would expect.
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 ? IIRC fixed width optimizations do not gain as
much as in earlier versions anyway. Then char(n) would have the benefit of
beeing trailing blank insensitive and having the optimal storage format.
Andreas
From | Date | Subject | |
---|---|---|---|
Next Message | Jason Tishler | 2002-11-18 11:45:29 | Re: [HACKERS] ipc-daemon |
Previous Message | Tim Bunce | 2002-11-18 10:26:20 | Re: DBD::PostgreSQL |