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

Re: int4 <-> bool casts

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: int4 <-> bool casts
Date: 2005-02-28 00:24:55
Message-ID: 200502280124.56320.peter_e@gmx.net (view raw or flat)
Thread:
Lists: pgsql-patches
Neil Conway wrote:
> > I believe I would have objected to an int/bool cast. I do so now
> > anyway.
>
> On what grounds?

I can think of a couple of reasons:

- Casting back and forth does not preserve information.  (This may be 
true for some other type pairs as well, but in this case it's true in 
almost every instance.)

- It's an arbitary definition that is not obviously supported by 
mathematical or similar principles.

- It opens the door for other silly casts like empty string => false, 
non-empty string => true.

- It's unnecessary because you can express the same thing using other 
expressions that clearly state what they do.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Responses

pgsql-patches by date

Next:From: Neil ConwayDate: 2005-02-28 00:32:50
Subject: Re: int4 <-> bool casts
Previous:From: Bruce MomjianDate: 2005-02-27 22:57:45
Subject: Re: win32 libpq build broken

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