Can connection pointer be obtained from PGresult? - Mailing list pgsql-general

From reina_ga@hotmail.com (Tony Reina)
Subject Can connection pointer be obtained from PGresult?
Date
Msg-id 272e4be7.0407121111.76fae85b@posting.google.com
Whole thread Raw
List 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

pgsql-general by date:

Previous
From: Brian Hirt
Date:
Subject: Re: (Again) Datacorruption using 7.4.2 on XFS/raid1
Next
From: CSN
Date:
Subject: Re: make install (in contrib) and PGDATA