Search Postgresql Archives

Lifetime of PQexecPrepared() returned value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 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.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux