initialization phase for user-defined functions - Mailing list pgsql-general

From g.p.ciceri
Subject initialization phase for user-defined functions
Date
Msg-id 39D24D26.1D33136D@acm.org
Whole thread Raw
List pgsql-general
hello all,
I'd like to know if it's possible with the new fmgr
(or if it was already possible with the existing 7.0x fmgr),
handle a sort of "initialization phase" for an user-defined
function.

I mean,
suppose I have to do a simple

select myfield, myfunction(myfield) from anhugetable

where myfunction is an user-defined C function that has to
perform a "slow" initialization task (say, connect to an external
server like LDAP) followed by the needed "fast" operation (say, do an
ldapsearch).

For all the examples I've seen, it seems to me that with the
current fmgr, myfunction has to perform the initialization
phase FOR EACH RECORD.

What I really would like to do is:

1. initialize the function on demand only one time
2. perform the needed "fast" operation for each record
3. unload the routine (and so clear the environment)

Any idea if it is possible (or will be possible), and how,
handle situations like this ???

Any suggestion will be appreciated, sorry for my poor
written English (the spoken version is even worse :-)).

Regards,
/gp

--
Discussion: How do you feel about Open Source firms making
millions through public offerings?

"I wish these companies were making the same millions without
distributing any non-free, user-subjugating software." --
                                             Richard Stallman

"We're not here to let the monkey dances." --
                                             g.p.

  Gian Paolo Ciceri        Via B.Diotti 45 - 20153 Milano MI ITALY
      CTO @ TiALabs        mobile :   ++39 347 4106213
                           eMail  :   gp.ciceri@acm.org
                           webSite:   http://www.tialabs.com

pgsql-general by date:

Previous
From: "Adam Lang"
Date:
Subject: Re: sql question
Next
From: Craig Anderson
Date:
Subject: Converting money types.