Any need to copy args before SPI C function callls SQL function? - Mailing list pgsql-general

From J. Greg Davidson
Subject Any need to copy args before SPI C function callls SQL function?
Date
Msg-id 1261689042.7438.17.camel@shevek.puuhonua.org
Whole thread Raw
List pgsql-general
I have some SPI C functions which dispatch to a selected PostgreSQL
function based on the the first argument value.  I have 3 questions
and am very open to any other advise you might have:

1. If any of the arguments are bigger than a word, e.g. text or arrays,
do I need to copy them into upper memory or can I just reuse the Datum
value passed to the C function in calling the SQL function?

2. When the returned value is bigger than a word I need to copy it
before returning it - is there a way for the SPI C function to do this
without having to know the detailed type of the value returned?  I'm
hoping there might be some handy formula with macros here.

3. I'm doing the calling using saved query plans - this seems to be the
only way to call an arbitrary function using the documented SPI API.
However, I see other code using undocumented functions to "directly"
call PostgreSQL functions from C, which looks easier.  I want to use the
fastest method possible that will not break with future releases - what
do you advise?

Thanks for your answers to these questions and thanks for the excellent
responses to my earlier questions!

Happy New Year,

_Greg

J. Greg Davidson

pgsql-general by date:

Previous
From: Doug El
Date:
Subject: Optimizing data layout for reporting in postgres
Next
From: Adrian Klaver
Date:
Subject: Re: Updating from 8.2 to 8.4