Re: string cast/compare broken? - Mailing list pgsql-hackers

From Zeugswetter Andreas SB SD
Subject Re: string cast/compare broken?
Date
Msg-id 46C15C39FEB2C44BA555E356FBCD6FA4961E1C@m0114.s-mxs.net
Whole thread Raw
In response to string cast/compare broken?  (Scott Royston <scroyston@mac.com>)
Responses Re: string cast/compare broken?
List pgsql-hackers
> 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).

Yes, I think this is inconvenient/unintuitive. If it is doable according to
standards, this should imho be fixed.

> If the conversion where varchar(5) --> char(5) then
> they would compare equal.

I am not sure, since, if the varchar stored 'S  ' then the comparison to a char 'S'
should probably still fail, since those spaces in the varchar are significant.
Informix compares them equal, so I guess argumentation can be made in that direction
too (that currently evades my understanding of intuitive reasoning :-).

Andreas


pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: string cast/compare broken?
Next
From: "Florian Helmberger"
Date:
Subject: Re: [PATCHES] Changes in /contrib/fulltextindex