session persistent data for plperl

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема session persistent data for plperl
Дата
Msg-id 402672F4.4050905@dunslane.net
обсуждение исходный текст
Ответы Re: session persistent data for plperl  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
The attached tiny patch (not intended for application yet) provides a 
space for plperl functions to create and share session persistent data, 
which I should think would increase the utility of plperl. Essentially 
it creates a hash called %session_globals which it then injects into the 
safe container where plperl functions live.

Comments are welcome - this is just a proof of concept. If this seems 
good to people, I will try to use a similar mechanism to "register" 
plperl functions so they can call each other.

cheers

andrew

(stupid) example use (using dollar quoting in psql ;-) ):

andrew=# create function perlfunc() returns text language plperl as $$
andrew$# if (!exists $session_globals{x}) { $session_globals{x} = 
'abcxyz'; }
andrew$# return $session_globals{x}++;
andrew$# $$;
CREATE FUNCTION
andrew=# select perlfunc();perlfunc
----------abcxyz
(1 row)

andrew=# select perlfunc();perlfunc
----------abcxza
(1 row)

andrew=# create function perlfunc2() returns text language plperl as $$
andrew$# if (!exists $session_globals{x}) { $session_globals{x} = 
'abcxyz'; }
andrew$# $session_globals{x} = reverse $session_globals{x};
andrew$# return $session_globals{x}++;
andrew$# $$;
CREATE FUNCTION
andrew=# select perlfunc2();perlfunc2
-----------bzxcba
(1 row)

andrew=# select perlfunc2();perlfunc2
-----------bbcxzb
(1 row)

andrew=# select perlfunc();perlfunc
----------bbcxzc
(1 row)




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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: Kerberos as source of user name? (Re: [BUGS] segfault in psql on x86_64)
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: session persistent data for plperl