pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christoph Haller <ch@rodos.fzk.de>
Cc: sad <sad@bankir.ru>
Cc: pgsql-sql@postgresql.org
Subject: Re: libpq-fe: PQgetvalue() ?
Date: Fri, 15 Oct 2004 10:21:29 -0400
Message-ID: <8899.1097850089@sss.pgh.pa.us> (raw)
In-Reply-To: <416F90ED.A65CB3B1@rodos.fzk.de>
References: <200410141634.22769.sad@bankir.ru>
	<416F90ED.A65CB3B1@rodos.fzk.de>

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 modify the data it points
     to, and one must explicitly copy the data into other storage if it
     is to be used past the lifetime of the PGresult structure itself.

			regards, tom lane



view thread (4+ messages)

Message-ID: <8899.1097850089@sss.pgh.pa.us>
Permalink:  ../8899.1097850089@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8899.1097850089@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ch@rodos.fzk.de, sad@bankir.ru
  Subject: Re: libpq-fe: PQgetvalue() ?
  In-Reply-To: <8899.1097850089@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox