Re: [HACKERS] Thread safe connection-name mapping in ECPG. Is it required?

2004-02-27 Thread Zeugswetter Andreas SB SD

 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.

I thought the main problem was an exec sql set connection :hostvar,
where hostvar is a string determined at runtime. Else above could be translated at 
precompile time to anything more efficient than a string search.

Oh, just noticed above is not standard, but sure is very useful.

Andreas

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [HACKERS] Thread safe connection-name mapping in ECPG. Is it required?

2004-02-26 Thread Michael Meskes
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: [EMAIL PROTECTED]
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


[HACKERS] Thread safe connection-name mapping in ECPG. Is it required?

2004-02-23 Thread Shridhar Daithankar
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

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster