Skip site navigation (1) Skip section navigation (2)

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

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Shridhar Daithankar <shridhar(at)frodo(dot)hserus(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Thread safe connection-name mapping in ECPG. Is it required?
Date: 2004-02-27 07:39:13
Message-ID: 20040227073913.GA3502@1 (view raw, whole thread or download thread mbox)
Lists: 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

Or what were you asking?

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

In response to


pgsql-hackers by date

Next:From: Michael MeskesDate: 2004-02-27 07:41:05
Subject: Re: CVS HEAD compile warning
Previous:From: Josh BerkusDate: 2004-02-27 07:27:21
Subject: Re: [pgsql-www] Collaboration Tool Proposal

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group