Re: Initializing Datums for use with SPI_execute_plan

From: "Jack Orenstein" <jack(dot)orenstein(at)gmail(dot)com>
To: andrew(at)supernews(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Initializing Datums for use with SPI_execute_plan
Date: 2006-09-18 18:40:27
Message-ID: 7ecd811f0609181140h5a3533ack34ff8fd294a39fe0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/14/06, Andrew - Supernews <andrew+nonews(at)supernews(dot)com> wrote:
> On 2006-09-14, "Jack Orenstein" <jack(dot)orenstein(at)gmail(dot)com> wrote:
> > I don't think I explained myself clearly. I have a C string (char*,
> > terminating zero) and a byte array (char*, possibly containing zeros,
> > and I know the length). I want to obtain Datums wrapping these values
> > that will be used to bind varchar and bytea columns, and I'm trying to
> > find out how to generate these Datums.
>
> One way:

Thank you, I hope you can help with some clarifications.

>
> bytea *my_bytea = (bytea *) palloc(byte_array_len + VARHDRSZ);
> memcpy(VARDATA(my_bytea), byte_array, byte_array_len);
> VARATT_SIZEP(my_bytea) = byte_array_len + VARHDRSZ;
>
> values[0] = DirectFunctionCall1(textin,CStringGetDatum(yourstring));

What is textin -- the name of a function?

> values[1] = PointerGetDatum(my_bytea);

One other thing is still unclear: What about signed/unsigned long? If
I have a C long, then how do I get a Datum that I can assign to
values[i]?

Jack Orenstein

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2006-09-18 18:47:43 Re: server resetting
Previous Message Volkan YAZICI 2006-09-18 18:21:46 Re: psql memory usage when creating delimited files