[postgis-users] Cast boolean to text

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Wed Oct 17 14:37:01 PDT 2007


On Wed, 2007-10-17 at 14:37 -0600, Pete Deffendol wrote:
> Hi,
> 
> After suddenly receiving errors in my Mapserver install, I tracked the 
> problem down to a missing cast from boolean to text type.  In earlier 
> releases of PostGIS (1.2.x), the lwpostgis.sql file did the following:
> 
> CREATE CAST (bool AS text) WITH FUNCTION ST_text(bool) AS IMPLICIT;
> 
> In version 1.3.1, this line is commented out of lwpostgis.sql.  I can't 
> find any reference to the change in the Changelog.  Was it disabled for 
> any particular reason?
> 
> Pete


Hi Pete,

Yes. Since boolean and text are PostgreSQL types (rather than PostGIS
types) then PostGIS really shouldn't be changing the default behaviour
of non-spatial data types. In general, implicit casts to text are not
good since they can cause problems when working with incorrect inputs,
and for this reason most of them have been removed from PostgreSQL 8.3.

The recommended advice would be to re-write your queries so that they
don't reply on the implicit cast (use the CAST() function if required),
although if you are happy with the risks involved then there is nothing
to stop you adding the implicit cast back in.


ATB,

Mark.

-- 
ILande - Open Source Consultancy
http://www.ilande.co.uk





More information about the postgis-users mailing list