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
passby value */
... Oid foid; /* oid of the function in pg_proc */ Oid language; /* oid of the
languagein pg_language */ int nargs; /* number of arguments */
Oid *argOidVect; /* oids of all the arguments */
... bool istrusted; /* trusted fn? */
and may be others too.
Vadim