Re: Casting INT4 to BOOL...

From: Sean Chittenden <chitt(at)speakeasy(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Casting INT4 to BOOL...
Date: 2004-10-11 02:38:25
Message-ID: A020DEEE-1B2E-11D9-91C8-000A95C705DC@speakeasy.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

>> Is there any reason why the backend doesn't cast an unquoted integer
>> to
>> a boolean value?
>
> Hidden cross-category typecasts are evil. I'd accept this as an
> explicit cast ('e' in pg_cast) but not automatic.

Alrighty. Do you want an updated patch for the single character tweak
or can you futz with it before committing? :)

> Also, what about the other direction? Providing a cast in only one
> direction is pretty inconsistent.

Ah... well, if you want that, I can provide that too. Personally, I
could care less about the BOOL->INT direction than INT->BOOL. In C++,
any bool value is either 0 or 1 and you can do such weirdness
(brokeness?) as:

bool val = false;
if (val == 0) { /* blah */ }

Anyway, with Qt, it converts bool values to integers. I think Qt's
probably right on this front in that the value 1 should be considered
true and 0 should be considered false. My $0.02. -sc

--
Sean Chittenden

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Shinji Teragaito 2004-10-11 07:31:27 Re: [PATCHES] HP-UX PA-RISC/Itanium 64-bit Patch and HP-UX
Previous Message Serguei Mokhov 2004-10-10 20:41:39 Translation update for 8.0: psql-ru