From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | session persistent data for plperl |
Date: | 2004-02-08 17:33:40 |
Message-ID: | 402672F4.4050905@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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)
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Hallgren | 2004-02-08 17:54:48 | Re: session persistent data for plperl |
Previous Message | Greg Stark | 2004-02-08 17:14:36 | Re: Kerberos as source of user name? (Re: [BUGS] segfault in psql on x86_64) |