Re: [GENERAL] SPI_execute_with_args call

2013-05-05 Thread Yuriy Rusinov
Hello ! There is one's more question, which way I have to determine that void * randBuf acceptable or not for bytea type ? Thanks in advance. On Fri, May 3, 2013 at 9:44 PM, Yuriy Rusinov yrusi...@gmail.com wrote: Thanks a lot, I have corrected and bug was fixed. On Fri, May 3, 2013 at

[GENERAL] SPI_execute_with_args call

2013-05-03 Thread Yuriy Rusinov
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 =

Re: [GENERAL] SPI_execute_with_args call

2013-05-03 Thread Gavin Flower
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

Re: [GENERAL] SPI_execute_with_args call

2013-05-03 Thread Yuriy Rusinov
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 gavinflo...@archidevsys.co.nzwrote: On 03/05/13 21:19, Yuriy Rusinov wrote: Hello, colleagues ! I have to write random number generator state into

Re: [GENERAL] SPI_execute_with_args call

2013-05-03 Thread Tom Lane
Yuriy Rusinov yrusi...@gmail.com writes: 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); This is a hard, error-prone, and

Re: [GENERAL] SPI_execute_with_args call

2013-05-03 Thread Yuriy Rusinov
Thanks a lot, I have corrected and bug was fixed. On Fri, May 3, 2013 at 6:42 PM, Tom Lane t...@sss.pgh.pa.us wrote: Yuriy Rusinov yrusi...@gmail.com writes: In C-function I do size_t nr_ins = strlen (insert into rand_state (state_rand) values ($1);); char * r_sql = (char *) palloc