On Fri, 2002-07-12 at 08:50, Tom Lane wrote: > Scott Royston <[EMAIL PROTECTED]> writes: > > [ various examples of comparing char and varchar ] > > I see no bug here. For the CHAR datatype, trailing spaces are defined > to be insignificant. For VARCHAR and TEXT, trailing spaces are > significant. If you want to compare a CHAR value to a VARCHAR or TEXT > value, your best bet is a locution like > rtrim(charval) = varcharval
I guess the strangest part was that both a.foo = 'S' and b.foo = 'S' but not a.foo=b.foo; (a.foo is varchar(5) , b.foo is char(5) ) I guess that tha 'S' that b.foo gets compared to is converted to 'S ' before comparison but when comparing varchar(5) and char(5) they are both compared by converting them to varchar which keeps the trailing spaces from char(5). If the conversion where varchar(5) --> char(5) then they would compare equal. I vaguely remember something in the standard about cases when comparing char() types should discard extra spaces. ------------- Hannu ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org