BUG #8156: PostGIS crash with immutable functions when immutable function throws an error

From: lr(at)pcorp(dot)us
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #8156: PostGIS crash with immutable functions when immutable function throws an error
Date: 2013-05-14 04:31:51
Message-ID: E1Uc6tz-0006eK-WE@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 8156
Logged by: Regina
Email address: lr(at)pcorp(dot)us
PostgreSQL version: 9.2.4
Operating system: Windows 7 64-bit compiled with visual c++ - EDB 64
Description:

Nothing to do yet unless its obvious to you folks what is wrong here.

I haven't determined if its an issue in how we are compiling PostGIS for
windows or something fundametally wrong in the 9.2 branch on how it handles
windows 64-bit.

Details in this ticket:

http://trac.osgeo.org/postgis/ticket/2185

The issue only seems to exhibit itself in PostgreSQL 9.2.2-9.2.4 (as I
recall 9.2.1 doesn't have this issue).

and it also only happens on windows 7-64bit and windows 2008 64-bit. As far
as I can tell windows 2003 64-bit with same build doesn't have the issue and
as I recall I can't replicate this issue testing under mingw64 either which
we use to compile.

We've only seen it with SQL functions that wrap a PostGIS c function and
that are marked IMMUTABLE STRICT and happens when fed invalid inputs that
would raise an error in the C function. If we take out the IMMUTABLE part
it works fine.

e.g.
This function will crash when used with invalid inputs. such as
ST_AsText('POINT(1 3 hi)')

CREATE OR REPLACE FUNCTION st_astext(text)
RETURNS text AS
' SELECT ST_AsText($1::geometry); '
LANGUAGE sql IMMUTABLE STRICT
COST 100;

This variant the function (note no immutable)

CREATE OR REPLACE FUNCTION st_astextNotImmut(text)
RETURNS text AS
' SELECT ST_AsText($1::geometry); '
LANGUAGE sql STRICT
COST 100;

Makes it not crash.

The 9.3beta1 doesn't have this issue. Nor does the latest 9.1 I have
tested.

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Kapila 2013-05-14 05:58:47 Re: Odd Behavior After Multiple Deletes
Previous Message Hugo J. Curti 2013-05-13 22:09:54 Re: BUG #8152: strange behavior regarding after triggers and inheritance