From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Bill Studenmund <wrstuden(at)netbsd(dot)org> |
Cc: | PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Package support for Postgres |
Date: | 2001-10-18 17:42:08 |
Message-ID: | Pine.LNX.4.30.0110172329010.628-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Bill Studenmund writes:
> Could you please give me an example of how to do this, say for plperl or
> plpython? Just showing how two functions made with CREATE FUNCTION can use
> global variables will be fine. This example will help me understand how
> they work.
For PL/Tcl you use regular Tcl global variables:
create function produce(text) returns text as '
global foo; set foo $1;
' language pltcl;
create function consume() returns text as '
global foo; return $foo;
' language pltcl;
There is also a mechanism for one procedure to save private data across
calls.
For PL/Python you use a global dictionary:
create function produce(text) returns text as '
GD["key"] = args[0]
' language plpython;
create function consume() returns text as '
return GD["key"]
' language plpython;
There is also a dictionary for private data.
For PL/Perl I'm not sure if something has been implemented. In C you can
use shared memory, and for PL/sh you would use temp files of course. ;-)
--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Burton | 2001-10-18 17:44:57 | Re: To Postgres Devs : Wouldn't changing the select limit |
Previous Message | Peter Eisentraut | 2001-10-18 17:41:45 | Create or replace function doesn't work so well |