Re: Thread safe connection-name mapping in ECPG. Is it

From: Shridhar Daithankar <shridhar_daithankar(at)persistent(dot)co(dot)in>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Thread safe connection-name mapping in ECPG. Is it
Date: 2004-02-28 08:40:27
Message-ID: 200402281410.27307.shridhar_daithankar@persistent.co.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday 27 February 2004 22:24, Lee Kindness wrote:
> Sort of related, I was thinking about adding some more thread-related
> code such that if a connection wasn't explicitely specified then the
> last connection SET or CONNECTed to for the current thread is used,
> rather than just the "last connection".
>
> But yeah, specifying the connection by variable (be it string or
> connection ptr) would be a definite step forward. Currently you cannot
> write a generic function like:
>
> int getit(char *using_connection)
> {
> EXEC SQL BEGIN DECLARE SECTION;
> char *s_connection = using_connection;
> int s_it;
> EXEC SQL END DECLARE SECTION;
>
> EXEC SQL AT :s_connection SELECT it INTO :s_it FROM some_table;
> return( s_it );
> }
>
> which could be run concurrently by multiple threads.

Consider another scenario. In a C++ class you want to contain a database
connection. The class needs to make n resources thread safe, including
database connection. Now each instance of class would be referring to
differnet database connection with same code.

Doing same with char strings, is just clean enough IMHO..

Shridhar

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dennis Bjorklund 2004-02-28 11:14:29 cvs lock
Previous Message Tom Lane 2004-02-28 04:28:25 Re: Schema comparisons