Re: string cast/compare broken?

Поиск
Список
Период
Сортировка
От Zeugswetter Andreas SB SD
Тема Re: string cast/compare broken?
Дата
Msg-id 46C15C39FEB2C44BA555E356FBCD6FA4961E1C@m0114.s-mxs.net
обсуждение исходный текст
Ответ на string cast/compare broken?  (Scott Royston <scroyston@mac.com>)
Ответы Re: string cast/compare broken?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Hannu Krosing
Дата:
Сообщение: Re: string cast/compare broken?
Следующее
От: "Florian Helmberger"
Дата:
Сообщение: Re: [PATCHES] Changes in /contrib/fulltextindex