Re: Request for additional SPI functions. - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Request for additional SPI functions.
Date
Msg-id 200402112200.i1BM05c19936@candle.pha.pa.us
Whole thread Raw
In response to Request for additional SPI functions.  ("Thomas Hallgren" <thhal@mailblocks.com>)
List pgsql-hackers
This seems like a reasonable request.  Care to submit a patch?

---------------------------------------------------------------------------

Thomas Hallgren wrote:
> Short story:
> I need two new functions in the Server Programming Interface (SPI) when
> mapping an ExecutionPlan to a Java prepared statement (pljava project).
> 
> Long story:
> My problem is that once a plan is prepared and I want to execute it, I send
> an array of java objects for the arguments. The SPI_cursor_open/SPI_execp of
> course expects the arguments to be Datum's and the mapper must convert java
> objects. Knowing the Oid of each type, this is not a problem. Those are
> hidden in the opaque execution plan (a void*). I'm all in favor of data
> hiding and reluctant to use spi_priv.h so I propose that you add the
> following two functions:
> 
> /*
> * Returns the number of arguments for the prepared plan.
> */
> int SPI_getargcount(void* plan)
> {
>     if (plan == NULL)
>     {
>         SPI_result = SPI_ERROR_ARGUMENT;
>         return -1;
>     }
>     return ((_SPI_plan*)plan)->nargs;
> }
> 
> /*
> * Returns the Oid representing the type id for argument at argIndex. First
> * parameter is at index zero.
> */
> Oid SPI_getargtypeid(void* plan, int argIndex)
>     {
>     if (plan == NULL || argIndex < 0 || argIndex >=
> ((_SPI_plan*)plan)->nargs)
>     {
>         SPI_result = SPI_ERROR_ARGUMENT;
>         return InvalidOid;
>     }
>     return ((_SPI_plan*)plan)->argtypes[argIndex];
> }
> 
> Regards,
> 
> Thomas Hallgren
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>                http://archives.postgresql.org
> 

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: libpq thread safety
Next
From: Bruce Momjian
Date:
Subject: Re: [PATCHES] client_encoding in dump file