Re: [HACKERS] PL/pgSQL and SPI

From: Vadim Mikheev <vadim(at)krs(dot)ru>
To: Jan Wieck <jwieck(at)debis(dot)com>
Cc: PostgreSQL HACKERS <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] PL/pgSQL and SPI
Date: 1999-01-27 17:43:21
Message-ID: 36AF5039.C8429CFC@krs.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jan Wieck wrote:
>
> ... And I've added two silly
> functions SPI_push() and SPI_pop() that simply
> increment/decrement the _SPI_curid value. This is
> required for calling ExecEvalExpr(), because there could
> be functions evaluated that use SPI themself and
> otherwise they could not connect to the SPI manager. They
> are dangerous and I'm in doubt if we should document
^^^^^^^^^
No more than improper call of SPI_finish()...

> them.
>
> 2. While doing the above I've encountered some bad details
> of the SPI manager and the executor. The Func and Oper
> nodes point to a function cache, which is initially NULL
> and is not copied by copyNode().
>
> For every call of SPI_execp() to execute a prepared plan,
> the whole plan is copied into the current memory context.
> Since this clears out the fcache, the executor has to do
> several syscache lookups for every function or operator
> hit during execution of the plan.
>
> Unfortunately I haven't found a way yet to avoid it.
> Anything I tried so far ended in coredumps or other
> misbehaviour. Maybe someone else has an idea.

Could we fill most of FunctionCache while parsing query ?!
We can do this for

int typlen; /* length of the return type */
int typbyval; /* true if return type is pass by value */
...
Oid foid; /* oid of the function in pg_proc */
Oid language; /* oid of the language in pg_language */
int nargs; /* number of arguments */

Oid *argOidVect; /* oids of all the arguments */
...
bool istrusted; /* trusted fn? */

and may be others too.

Vadim

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-01-27 17:50:35 Re: [HACKERS] TEMP tables
Previous Message Jan Wieck 1999-01-27 17:08:25 PL/pgSQL and SPI