Re: casting BOOL to somthng

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: sad <sad(at)bankir(dot)ru>
Cc: Michael Glaesemann <grzm(at)myrealbox(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: casting BOOL to somthng
Date: 2004-09-01 07:16:03
Message-ID: 20040901001230.O60275@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Wed, 1 Sep 2004, sad wrote:

> On Wednesday 01 September 2004 09:24, Stephan Szabo wrote:
> > On Wed, 1 Sep 2004, sad wrote:
> > > On Tuesday 31 August 2004 17:49, Michael Glaesemann wrote:
> > > > On Aug 31, 2004, at 8:24 PM, sad wrote:
> > > > > and i am still desire to know _WHY_ there are no predefined cast for
> > > > > BOOL ?
> > > > > and at the same time there are predefined casts for INT and
> > > > > FLOAT......
> > > >
> > > > I think the main reason is what is the proper textual representation of
> > > > BOOLEAN? True, PostgreSQL returns 't' as a representation for the
> > > > BOOLEAN value TRUE, but some people might want it to return 'TRUE' or
> > > > 'true' or other representations. Picking one is perhaps arbitrary.
> > >
> > > There are many (infinite number) of INT representations,
> > > "Picking one is perhaps arbitrary." But you poke one and using it.
> >
> > There's a fairly accepted convention for integer representations.
> > There's no such convention for boolean representations.
>
> then why do you print its value on a screen ?!

There's a difference between an output function and a cast to text.
One gives you an external representation of the data for end use. The
other gives you an internal representation for manipulation.

Just because true is displayed in psql as 't' and false is displayed in
psql as 'f' does not mean that an expression like (true::text ||
false::text) has any conventional meaning let alone 'tf'.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2004-09-01 07:22:26 Re: casting BOOL to somthng
Previous Message Michael Glaesemann 2004-09-01 07:03:51 Re: casting BOOL to somthng