immutable functions

Поиск
Список
Период
Сортировка
От Andy Chambers
Тема immutable functions
Дата
Msg-id CAAfW55ohFdSOgczfRc0Tt=ZZahkAFd0J1gSCHhMVnf64-MD6FA@mail.gmail.com
обсуждение исходный текст
Ответы Re: immutable functions
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Ronan Dunklau
Дата:
Сообщение: Re: Any experiences with Foreign Data Wrappers (FDW) like mysql_fdw, odbc_fdw, www_fdw or odbc_fdw?
Следующее
От: Heiko Wundram
Дата:
Сообщение: Limiting number of connections to PostgreSQL per IP (not per DB/user)?