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

From Stephan Szabo
Subject Re: Casting INT4 to BOOL...
Date
Msg-id 20041011225149.I37114@megazone.bigpanda.com
Whole thread Raw
In response to Re: Casting INT4 to BOOL...  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
On Mon, 11 Oct 2004, Tom Lane wrote:

> Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> > On Mon, 11 Oct 2004, Sean Chittenden wrote:
> >> 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.
>

[strawman snipped]

> The question for an integer-to-bool conversion is what is useful and
> expected behavior for that conversion; I don't think that's necessarily
> the same as what the textual conversion should do.
>
> A possibly useful analogy is that real-to-integer coercion rounds off
> fractions; it doesn't error out, even though the integer input function
> won't take a string that includes a decimal point.

Well, technically AFAICS, a string to integer conversion has to follow the
same general rules as numeric to integer by SQL99.  So a varchar value of
'2.5' cast to int should work and give you the same value as 2.5 cast to
int (or at least, I can't see any other way to read 6.22GR6b). But since
we do odd things with quoted literals, it makes the case anyway and I
withdraw the comment.

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: fix vpath build break
Next
From: Peter Eisentraut
Date:
Subject: Re: Casting INT4 to BOOL...