[GENERAL] Lifetime of PQexecPrepared() returned value
| От | Igor Korot |
|---|---|
| Тема | [GENERAL] Lifetime of PQexecPrepared() returned value |
| Дата | |
| Msg-id | CA+FnnTwG9qgqu3p0HcibiBq3=CN7wHoZxeNhtH8vy3+yVyFSCQ@mail.gmail.com обсуждение исходный текст |
| Ответы |
Re: [GENERAL] Lifetime of PQexecPrepared() returned value
Re: [GENERAL] Lifetime of PQexecPrepared() returned value |
| Список | pgsql-general |
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 );
MyObject *obj = new MyObject( foo, bar );
if( SetAdditionalProperties( obj ) )
{
result = 1;
break;
}
}
PQclear( res );
}
int SetAdditionalProperties(MyObject &obj)
{
// a call to PQexecParams() here
}
[/code]
If the call to SetAdditionalProperties() fails, I get a crash on
PQclear(), stating that
the pointer is not allocated.
Am I missing something? How do I fix the crash?
Thank you.
В списке pgsql-general по дате отправления: