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

From Shridhar Daithankar
Subject Thread safe connection-name mapping in ECPG. Is it required?
Date
Msg-id 200402232127.40158.shridhar@frodo.hserus.net
Whole thread Raw
Responses Re: Thread safe connection-name mapping in ECPG. Is it required?  (Michael Meskes <meskes@postgresql.org>)
List pgsql-hackers
Hi all,

I was just going thr. the ecpg sources checking for thread safety. 

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.

Just a thought... 
Shridhar


pgsql-hackers by date:

Previous
From: Lamar Owen
Date:
Subject: Re: Heads up: 7.3.6 and 7.4.2 coming soon
Next
From: Peter Eisentraut
Date:
Subject: Re: Pl/Java - next step?