Обсуждение: text cast to bool bug

Поиск
Список
Период
Сортировка

text cast to bool bug

От
Laczi József
Дата:
I think this is a funny bug:

select ('TRUE'::TEXT)::BOOL;bool
------f

but:

select ('TRUE'::varchar(4))::BOOL;bool
------tor

select ('true'::TEXT)::BOOL;bool
------t


My postgresql version:
PostgreSQL 8.3.4


Laczi József




Re: text cast to bool bug

От
Pavel Stehule
Дата:
Hello

It works on my server. Do you have a some specific configuration?

postgres=3D# select ('true'::text)::bool;
 bool
------
 t
(1 row)

I am checked 8.3, 8.4, 9.0.

Regards
Pavel Stehule

2010/3/18 Laczi J=C3=B3zsef <laczi.jozsef@ritek.hu>:
> I think this is a funny bug:
>
> select ('TRUE'::TEXT)::BOOL;
> bool
> ------
> f
>
> but:
>
> select ('TRUE'::varchar(4))::BOOL;
> bool
> ------
> t
> or
>
> select ('true'::TEXT)::BOOL;
> bool
> ------
> t
>
>
> My postgresql version:
> PostgreSQL 8.3.4
>
>
> Laczi J=C3=B3zsef
>
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

Re: text cast to bool bug

От
CaT
Дата:
On Thu, Mar 18, 2010 at 11:37:53AM +0100, Pavel Stehule wrote:
> postgres=# select ('true'::text)::bool;
>  bool
> ------
>  t
> (1 row)
>
> I am checked 8.3, 8.4, 9.0.

What about the 'TRUE' (all caps) case? Note the blow:

> 2010/3/18 Laczi József <laczi.jozsef@ritek.hu>:
> > I think this is a funny bug:
> >
> > select ('TRUE'::TEXT)::BOOL;
> > bool
> > ------
> > f
...
> > select ('true'::TEXT)::BOOL;
> > bool
> > ------
> > t

--
  "A search of his car uncovered pornography, a homemade sex aid, women's
  stockings and a Jack Russell terrier."
    - http://www.news.com.au/story/0%2C27574%2C24675808-421%2C00.html

Re: text cast to bool bug

От
Tom Lane
Дата:
Laczi József <laczi.jozsef@ritek.hu> writes:
> I think this is a funny bug:
> select ('TRUE'::TEXT)::BOOL;
>  bool
> ------
>  f

Works here:

regression=# select ('TRUE'::TEXT)::BOOL;bool
------t
(1 row)

(I'm checking 8.3.10, but that code hasn't changed in a long time.)

Maybe you have created a custom text-to-bool cast that is catching this
operation, and the cast function is case-sensitive?
        regards, tom lane