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

Re: Boolean casting in 7.3 -> changed?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ian Barwick <barwick(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Boolean casting in 7.3 -> changed?
Date: 2002-11-27 05:23:15
Message-ID: 14419.1038374595@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Ian Barwick <barwick(at)gmx(dot)net> writes:
> in 7.3 the following no longer works:
>   template1=> select 0::bool;
>   ERROR:  Cannot cast type integer to boolean

Note that both old and new versions reject
	select 0::int4::bool;

I believe the behavioral change is a consequence of Rod Taylor's
DOMAIN patch: it essentially eliminated the old parser_typecast_constant()
routine in order to ensure that constraints associated with a domain
would get applied in examples like "select 0::domaintypename".

I wasn't totally happy with Rod's patch, for reasons that I couldn't put
my finger on at the time, but perhaps my hindbrain understood that there
would be noticeable behavioral changes.  But be that as it may, the code
is in there now and is unlikely to get reverted.  There isn't any place
in our docs that promises that you can coerce an integer-looking literal
to bool --- and one could argue that allowing such is just opening the
door for typos.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Gavin SherryDate: 2002-11-27 06:50:15
Subject: Re: updating on views
Previous:From: Bruce MomjianDate: 2002-11-27 04:56:27
Subject: Interface update for 7.3

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