Skip site navigation (1) Skip section navigation (2)

Re: Casting INT4 to BOOL...

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Sean Chittenden <chitt(at)speakeasy(dot)net>,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 06:02:49
Message-ID: 20041011225149.I37114@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-patches
On Mon, 11 Oct 2004, Tom Lane wrote:

> Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)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.

In response to

pgsql-patches by date

Next:From: Peter EisentrautDate: 2004-10-12 07:05:19
Subject: Re: Casting INT4 to BOOL...
Previous:From: Neil ConwayDate: 2004-10-12 04:48:49
Subject: Re: fix vpath build break

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group