Re: libpq-fe: PQgetvalue() ?

Поиск
Список
Период
Сортировка
От ljb
Тема Re: libpq-fe: PQgetvalue() ?
Дата
Msg-id ckn6uj$g28$2@news.hub.org
обсуждение исходный текст
Ответ на libpq-fe: PQgetvalue() ?  (sad <sad@bankir.ru>)
Список pgsql-sql
sad@bankir.ru wrote:
> hi
>
> does PQgetvalue() allocate memory rof its result, it returns ?
> the answer will help me in problem:
> should i free some cstring_variable if
> { cstring_variable=PQgetvalue(pgresult_variable,0,0); }
> and could i PQclear(pgresult_varible) while cstring_varible is in use.

From the documentation:   The pointer returned by PQgetvalue points to storage that is part of the PGresult structure.
Oneshould not modify the data it points to, and one must explicitly copy the data into other storage if it is to be
usedpast the lifetime of the PGresult structure itself.
 

So no, you must not free your copy of the pointer returned by PQgetvalue,
and no, once you PQclear the result your pointer is not valid. You should


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Fang Genjie"
Дата:
Сообщение: the problem of createlang!
Следующее
От: Stephan Fiebrandt
Дата:
Сообщение: need query advice