Re: Casting INT4 to BOOL... - Mailing list pgsql-patches

From Sean Chittenden
Subject Re: Casting INT4 to BOOL...
Date
Msg-id A020DEEE-1B2E-11D9-91C8-000A95C705DC@speakeasy.net
Whole thread Raw
In response to Re: Casting INT4 to BOOL...  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Casting INT4 to BOOL...
List 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


pgsql-patches by date:

Previous
From: "Serguei Mokhov"
Date:
Subject: Translation update for 8.0: psql-ru
Next
From: Shinji Teragaito
Date:
Subject: Re: [HACKERS] HP-UX PA-RISC/Itanium 64-bit Patch and HP-UX