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

From Michael Meskes
Subject Re: Thread safe connection-name mapping in ECPG. Is it required?
Date
Msg-id 20040227073913.GA3502@1
Whole thread Raw
In response to Thread safe connection-name mapping in ECPG. Is it required?  (Shridhar Daithankar <shridhar@frodo.hserus.net>)
Responses Re: Thread safe connection-name mapping in ECPG. Is it
List pgsql-hackers
On Mon, Feb 23, 2004 at 09:27:40PM +0530, Shridhar Daithankar wrote:
> It looks like the mutex protects the connections list in connection.c. I do 
> not like that from a application developers perspective.
> 
> If I am developing an application and using multiple connections in multiple 
> threads, I have to store a connection name for each connection as C string. 
> Of course, I also have to protect it across thread so that I can rightly tell 
> ecpg what connection I would be talking to next.
> 
> If an application can take care of a C string, it can also take care of a 
> connection structure. On top of it, it eliminates the list lookup. The 
> potential performance gain could be worth it if there are hundreds of 
> connections and a busy website/application server.
> 
> What I wonder is, do we really need to maintain that level of lookup? Can't we 
> just say a connection is a 'struct connection *' which should be opaque and 
> should not be touched or poked inside, just like PGConn.

I'm not sure I understand you correctly. The SQL standard says you can
call your statement as this:
exec sql at CONNECTION select 1;

Here CONNECTION of course is a string, the name of the connection. So,
yes, we have to maintain that list to make sure we get the right
connection.

Or what were you asking?

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!


pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: [pgsql-www] Collaboration Tool Proposal
Next
From: Michael Meskes
Date:
Subject: Re: CVS HEAD compile warning