Can connection pointer be obtained from PGresult?

From: reina_ga(at)hotmail(dot)com (Tony Reina)
To: pgsql-general(at)postgresql(dot)org
Subject: Can connection pointer be obtained from PGresult?
Date: 2004-07-12 19:11:01
Message-ID: 272e4be7.0407121111.76fae85b@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I inherited some C code that works as a series of libraries using
libpq. One of the libraries has an input to it of a PGresult pointer,
but not of a PGconnect pointer. Within the library, the code tries to
determine the host name of the connection by doing the following
trick:

strcpy (host,PQhost(((PGresult*)*pgresult)->xconn));

This worked fine in the past (v. 7.0) despite being warned against in
the documentation since directly accessing the structures in PGresult
seems to be off limits (I suppose in case its structure changes with
PG version).

I'm trying to think of a workaround that would do things right without
having to explicitly pass PGconn pointer into the code. Perhaps this
can't be done, but I thought I'd throw out the question and wait for
the verbal abuse.

-Tony

Browse pgsql-general by date

  From Date Subject
Next Message Brian Hirt 2004-07-12 19:22:02 Re: (Again) Datacorruption using 7.4.2 on XFS/raid1
Previous Message Bruce Momjian 2004-07-12 19:03:47 Re: Latitude/Longitude data types and functions