From: | Sean Chittenden <chitt(at)speakeasy(dot)net> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
Cc: | Neil Conway <neilc(at)samurai(dot)com>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: Casting INT4 to BOOL... |
Date: | 2004-10-12 07:58:29 |
Message-ID: | 8154E140-1C24-11D9-BCB2-000A95C705DC@speakeasy.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
>>> The patch treats any non-zero value as "true". Is that the behavior
>>> we
>>> want, or should we only allow "1" as an integer representation of
>>> "true"? (I'm not sure myself, I just don't think copying C here is
>>> necessarily the best guide.)
>>
>> I would posit that this is the desired behavior as it's consistent
>> with
>> every language I can think of.
>
> However, AFAIK it's inconsitent with the type input function which
> supports '1' and '0' but not other integers.
I actually pondered that and came up with a patch that I didn't submit.
False has a very specific set of possibilities that can be reasonably
easily defined. True, is anything not false. I eventually didn't
submit it because I was able to convince myself with the following
statement.
Regardless of whether or not true is any non-zero value, this is a
database where data and its inputs must be validated and constrained to
a given set of probable and process-able possibilities. Perl's
decision to let any non-empty string be true doesn't mean a database
should take any nonfalse-like value and assume it should be true.
42::BOOL == TRUE, on the other hand, has a long mathematical president
wherein non-zero values are true and zero values are false.
Unlike the previous int4_bool()/bool_int4() patch which addresses a
mathematical technicality, accepting different string values as true or
false seems exceedingly dangerous, though probably an okay
interpretation. I went one step further, however, and tested for an
empty string as a valid false value (one of Perl's false values).
Since this subject isn't ever going to get resolved, I don't think it's
worth trudging down this path, but, I thought the extreme is helpful in
justifying the current string->bool conversion and the new
int4->bool/bool->int4 conversion, IMHO. -sc
... I wonder what color this bikeshed is gunna be...
Attachment | Content-Type | Size |
---|---|---|
patch.txt | text/plain | 1.2 KB |
unknown_filename | text/plain | 22 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Page | 2004-10-12 11:49:33 | Re: Static build of libpq fails |
Previous Message | Dave Page | 2004-10-12 07:28:20 | Re: libpq.dll on win32 |