From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | char(n) to varchar or text conversion should strip trailing spaces |
Date: | 2002-11-15 22:54:39 |
Message-ID: | 2468.1037400879@sss.pgh.pa.us |
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.
Comments?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-11-15 23:29:15 | Re: Transaction safe Truncate |
Previous Message | Manfred Koizar | 2002-11-15 22:11:52 | Re: RI_FKey_check: foreign key constraint blocks parallel |