Re: SPI_prepare, SPI_execute_plan do not return rows when using parameters

From: Dennis Jenkins <dennis(dot)jenkins(at)sbcglobal(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SPI_prepare, SPI_execute_plan do not return rows when using parameters
Date: 2005-10-05 21:34:06
Message-ID: 20051005213406.5932.qmail@web81305.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Dennis Jenkins <dennis(dot)jenkins(at)sbcglobal(dot)net>
> writes:
> > My problem is that a query that should be
> returning a
> > row is returning zero rows when I use a
> parametrized
> > query.
>
> You're passing the wrong parameter value, and
> probably not declaring it
> to be the right type either. CHAROID is not the
> type you think it is
> (BPCHAROID is what you want), and "CStringGetDatum"
> is not the way to
> convert a C string into a char(N) datum. The most
> bulletproof way
> to do the latter is to use DirectFunctionCall3 to
> invoke bpcharin().
>

Thank you. I was able to make the code work. I
changed "CHAROID" to "BPCHAROID" and the bind[0] line
now reads:

bind[0] = DirectFunctionCall3(bpcharin,
(Datum)transit, 0 /*unused*/ , 9 + sizeof(VARHDRSZ));

However, I must admit that I could find no usable
documentation for either "DirectFunctionCall3" and
"bpcharin" online. I had to extract the source code
to the engine and read
"src/backend/utils/adt/varchar.c" to learn what
arguments to pass to DFC3.

If I create a sample stored procedure that uses the
above functions and submit it to "the documentation
people", would they want it? Would they include it in
the docs? Who are these magic people and where do I
find them?

Thank you very much for your time. Our code is now
working, so I'm a happy camper.

Dennis Jenkins

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2005-10-05 22:17:52 Re: Untyped result (setof / rowset) from Functions ?
Previous Message Zlatko Matić 2005-10-05 20:33:01 Re: [INTERFACES] [ODBC] Unbound text box, Text > 255 characters, MSAccess/PostgreSQL