Re: libpq-fe: PQgetvalue() ? - Mailing list pgsql-sql

From Tom Lane
Subject Re: libpq-fe: PQgetvalue() ?
Date
Msg-id 8899.1097850089@sss.pgh.pa.us
Whole thread Raw
In response to Re: libpq-fe: PQgetvalue() ?  (Christoph Haller <ch@rodos.fzk.de>)
List pgsql-sql
Christoph Haller <ch@rodos.fzk.de> writes:
> You cannot PQclear(pgresult_varible) while cstring_varible is in use.
> You do not need to free cstring_variable, PQclear(pgresult_varible) will do.
> I personally prefer to allocate local memory, "strcpy" PQgetvalue,
> and then PQclear. But that's a matter of taste, I suppose.

That is surely overkill.

PQgetvalue doesn't allocate new memory for its result.  The docs are
reasonably clear, I thought:
    The pointer returned by PQgetvalue points to storage that is part    of the PGresult structure. One should not
modifythe data it points    to, and one must explicitly copy the data into other storage if it    is to be used past
thelifetime of the PGresult structure itself.
 
        regards, tom lane


pgsql-sql by date:

Previous
From: "C. Bensend"
Date:
Subject: Re: Inserting into table only if the row does not already
Next
From: Steven Klassen
Date:
Subject: Re: Inserting into table only if the row does not already