Re: Thread safe connection-name mapping in ECPG. Is it - Mailing list pgsql-hackers

From Shridhar Daithankar
Subject Re: Thread safe connection-name mapping in ECPG. Is it
Date
Msg-id 200402281410.27307.shridhar_daithankar@persistent.co.in
Whole thread Raw
In response to Re: Thread safe connection-name mapping in ECPG. Is it  (Lee Kindness <lkindness@csl.co.uk>)
List 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


pgsql-hackers by date:

Previous
From: elein
Date:
Subject: Re: [pgsql-www] Collaboration Tool Proposal
Next
From: janos@intland.com
Date:
Subject: Re: Collaboration Tool Proposal