Re: [GENERAL] Lifetime of PQexecPrepared() returned value

2017-08-05 Thread Tom Lane
Igor Korot writes: > However it leads to another question - should PQclear set the pointer to NULL? C doesn't provide any reasonable way to do that. The argument of PQclear needn't even be an lvalue; for example, if you're not too concerned about error checking, it's not unreasonable to write

Re: [GENERAL] Lifetime of PQexecPrepared() returned value

2017-08-05 Thread Igor Korot
Hi, guys, On Fri, Aug 4, 2017 at 5:01 PM, Tom Lane wrote: > Igor Korot writes: >> I have a following piece of code: > >> [code] >> PGresult *res = PQexecPrepared(); >> status = PQresultStatue( res ); >> if( status == PGRES_TUPLES_OK ) >> { >> for( int j = 0; j < PQntuples( res ); j++ ) >>

Re: [GENERAL] Lifetime of PQexecPrepared() returned value

2017-08-04 Thread Tom Lane
Igor Korot writes: > I have a following piece of code: > [code] > PGresult *res = PQexecPrepared(); > status = PQresultStatue( res ); > if( status == PGRES_TUPLES_OK ) > { > for( int j = 0; j < PQntuples( res ); j++ ) > { > char *foo = PQgetValue( res, j, 0 ); > char *bar

Re: [GENERAL] Lifetime of PQexecPrepared() returned value

2017-08-04 Thread Igor Korot
Hi, Michael, On Fri, Aug 4, 2017 at 3:26 PM, Michael Paquier wrote: > On Fri, Aug 4, 2017 at 9:12 PM, Igor Korot wrote: >> Am I missing something? How do I fix the crash? > > Based on what I can see here, I see nothing wrong. Now it is hard to > reach any conclusion with the limited information

Re: [GENERAL] Lifetime of PQexecPrepared() returned value

2017-08-04 Thread Michael Paquier
On Fri, Aug 4, 2017 at 9:12 PM, Igor Korot wrote: > Am I missing something? How do I fix the crash? Based on what I can see here, I see nothing wrong. Now it is hard to reach any conclusion with the limited information you are providing. -- Michael -- Sent via pgsql-general mailing list (pgsq

[GENERAL] Lifetime of PQexecPrepared() returned value

2017-08-04 Thread Igor Korot
Hi, ALL, I have a following piece of code: [code] PGresult *res = PQexecPrepared(); status = PQresultStatue( res ); if( status == PGRES_TUPLES_OK ) { for( int j = 0; j < PQntuples( res ); j++ ) { char *foo = PQgetValue( res, j, 0 ); char *bar = PQgetValue( res, j, 1 );