From: | Andy Chambers <achambers(at)mcna(dot)net> |
---|---|
To: | pgsql-general List <pgsql-general(at)postgresql(dot)org> |
Subject: | immutable functions |
Date: | 2011-11-29 13:28:24 |
Message-ID: | CAAfW55ohFdSOgczfRc0Tt=ZZahkAFd0J1gSCHhMVnf64-MD6FA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Heiko Wundram | 2011-11-29 13:49:37 | Limiting number of connections to PostgreSQL per IP (not per DB/user)? |
Previous Message | Ronan Dunklau | 2011-11-29 12:06:40 | Re: Any experiences with Foreign Data Wrappers (FDW) like mysql_fdw, odbc_fdw, www_fdw or odbc_fdw? |