| From: | Yuriy Rusinov <yrusinov(at)gmail(dot)com> |
|---|---|
| To: | POSTGRES <pgsql-general(at)postgresql(dot)org> |
| Subject: | SPI_execute_with_args call |
| Date: | 2013-05-03 09:19:40 |
| Message-ID: | CAA5U4sw2=uGjNCjOry1uBC-os_aEGx7BRHQ3myXRKLFYRGXHUA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gavin Flower | 2013-05-03 10:31:59 | Re: SPI_execute_with_args call |
| Previous Message | Yang Zhang | 2013-05-03 06:44:33 | Curious why planner can't handle NOT IN |