Thread: Request for feature - ECPGget_PGconn

Request for feature - ECPGget_PGconn

From
Mike Aubury
Date:
Request Overview
----------------
Add a function to return the current PGConn used within ecpg..


Background
----------
For years now within the Aubit4GL project we've been able to access the PGConn 
record used by ecpg by the highly dubious means of accessing an internal 
record within ecpg (which has now been removed/hidden). 
It would be really useful if we could get at the PGConn connection via a 
formal API/function call...

This would be useful to others as it would allow libpq calls on the currently 
open connection to use features for which there is no direct ecpg equivilent, 
or where the functionality has already been implemented using libpq calls.
(The ability to drop to a lower level of abstraction is common in most db 
orientated languages/language extensions like esql/c.)



Implementation
--------------

This could be implemented by adding the following code to the existing 
ecpglib/connect.c file : 
       PGconn* ECPGget_PGconn(const char *connection_name) {        struct connection * con;
con=ecpg_get_connection(connection_name);       if (con==NULL) return NULL;    
 
        return con->connection;       }




TIA


-- 
Mike Aubury

Aubit Computing Ltd is registered in England and Wales, Number: 3112827
Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ




Re: Request for feature - ECPGget_PGconn

From
Dave Cramer
Date:
Tom,

I believe you were the one to object to this proposal pre 8.3 ?

To me it seems innocuous. Most high level db abstractions allow access  
to the underlying connection.

Dave
On 17-Mar-08, at 7:26 AM, Mike Aubury wrote:

>
> Request Overview
> ----------------
> Add a function to return the current PGConn used within ecpg..
>
>
> Background
> ----------
> For years now within the Aubit4GL project we've been able to access  
> the PGConn
> record used by ecpg by the highly dubious means of accessing an  
> internal
> record within ecpg (which has now been removed/hidden).
> It would be really useful if we could get at the PGConn connection  
> via a
> formal API/function call...
>
> This would be useful to others as it would allow libpq calls on the  
> currently
> open connection to use features for which there is no direct ecpg  
> equivilent,
> or where the functionality has already been implemented using libpq  
> calls.
> (The ability to drop to a lower level of abstraction is common in  
> most db
> orientated languages/language extensions like esql/c.)
>
>
>
> Implementation
> --------------
>
> This could be implemented by adding the following code to the existing
> ecpglib/connect.c file :
>
>        PGconn* ECPGget_PGconn(const char *connection_name) {
>         struct connection * con;
>         con=ecpg_get_connection(connection_name);
>         if (con==NULL) return NULL;
>
>         return con->connection;
>        }
>
>
>
>
> TIA
>
>
> -- 
> Mike Aubury
>
> Aubit Computing Ltd is registered in England and Wales, Number:  
> 3112827
> Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ
>
>
>
> -- 
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers



Re: Request for feature - ECPGget_PGconn

From
Michael Meskes
Date:
On Mon, Mar 17, 2008 at 11:26:59AM +0000, Mike Aubury wrote:
> Add a function to return the current PGConn used within ecpg..

I still consider such a feature is a little bit hackish, but I also
think Mike has some valid points. And given that adding this patch does
not create side effects I will commit it if no one objects.

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!