The documentation has this to say about immutable functions...

> or otherwise use information not directly present in its argument list

If the arguments are "row variables", does this allow access to the
data in the row?  For example, is it safe to make the following
function definition immutable.

CREATE OR REPLACE FUNCTION distance(geocodes, geocodes)
  RETURNS double precision AS
$BODY$
  select case $1.zip =  $2.zip
           when      true then 0
           else      ((acos(sin(($1.lat) * (pi()/180)) *
                  sin(($2.lat)*(pi()/180)) + cos(($1.lat)*(pi()/180)) *
                  cos(($2.lat)*(pi()/180)) * cos(($1.lon - $2.lon) *
                  (pi()/180))))*(180/pi())* 60 * 1.1515)
         end;
$BODY$
LANGUAGE sql immutable
COST 100;

Cheers,
Andy

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to