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

Поиск
Список
Период
Сортировка
От Shridhar Daithankar
Тема Re: Thread safe connection-name mapping in ECPG. Is it
Дата
Msg-id 200402281410.27307.shridhar_daithankar@persistent.co.in
обсуждение исходный текст
Ответ на Re: Thread safe connection-name mapping in ECPG. Is it  (Lee Kindness <lkindness@csl.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: elein
Дата:
Сообщение: Re: [pgsql-www] Collaboration Tool Proposal
Следующее
От: janos@intland.com
Дата:
Сообщение: Re: Collaboration Tool Proposal