From: | Bill Studenmund <wrstuden(at)netbsd(dot)org> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Package support for Postgres |
Date: | 2001-10-17 13:48:05 |
Message-ID: | Pine.NEB.4.33.0110170601040.3492-100000@vespasia.home-net.internetconnect.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, 18 Oct 2001, Peter Eisentraut wrote:
> 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.
Private to what?
> 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. ;-)
Thank you. I can now experiment with them to see how they do.
I've never thought of adding package variables for C routines; there are
other options open. :-)
Oh, by shared memory, do you mean SYSV Shared Memory (like how the
backends talk) or just memory shared between routines? I ask as part of
the idea with these variables is that they are backend-specific. So C
routines actually should NOT used SYSV Shared Mem. :-)
Take care,
Bill
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-10-17 14:21:08 | Re: Column names - time |
Previous Message | Ron de Jong | 2001-10-17 11:45:22 | How do I get a list of DB's or Tables with a postgres SQL statement? |