Re: SPI_execute_with_args call

From: Yuriy Rusinov <yrusinov(at)gmail(dot)com>
To: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
Cc: POSTGRES <pgsql-general(at)postgresql(dot)org>
Subject: Re: SPI_execute_with_args call
Date: 2013-05-03 10:56:55
Message-ID: CAA5U4sxZ--LSyLccXN-7Y8b1WX2n4dt1ipDZFOXRqMiZQW_U6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm sorry !

But if I commented SPI_execute_with_args call, then all others works
without bugs.

On Fri, May 3, 2013 at 2:31 PM, Gavin Flower
<GavinFlower(at)archidevsys(dot)co(dot)nz>wrote:

> On 03/05/13 21:19, Yuriy Rusinov wrote:
>
> Hello, colleagues !
>
> I have to write random number generator state into database table
> Table structure is
> table rand_state
> {
> id serial not null primary key,
> state_rand bytea
> };
>
> In C-function I do
> size_t nr_ins = strlen ("insert into rand_state (state_rand) values
> ($1);");
> char * r_sql = (char *) palloc (nr_ins + 1);
> strncpy (r_sql, "insert into rand_state (state_rand) values ($1);",
> nr_ins);
>
> Oid * oids = (Oid *)palloc (sizeof (Oid));
> Datum * val = PointerGetDatum (randBuf);
> *oids = BYTEAOID;
> const char * nulls = "NULL";
> int rins = SPI_execute_with_args (r_sql, 1, oids, val, nulls, false, 1);
>
> randBuf is a void * pointer that contains random number generator state,
> when I try to execute SPI_execute_with_args (r_sql, 1, oids, val, nulls,
> false, 1); I receive error
> The connection to the server was lost. Attempting reset: Failed.
> Could you give some work examples for SPI_execute_with_args because I
> didn't find them in documentation.
>
> Thanks a lot.
>
> --
> Best regards,
> Sincerely yours,
> Yuriy Rusinov.
>
> I can't answer your question.
>
> However, I can say that PRIMARY KEY implies NOT NULL (also an UNIQUE
> index), so you don't need to explicitly add NOT NULL when you are specifying
> PRIMARY KEY!
>
>
> Cheers,
> Gavin
>

--
Best regards,
Sincerely yours,
Yuriy Rusinov.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-05-03 14:29:30 Re: Curious why planner can't handle NOT IN
Previous Message mark_r 2013-05-03 10:33:33 Re: Simple, free PG GUI/query tool wanted