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

Re: [INTERFACES] libpq + multiple connections ...

From: The Hermit Hacker <scrappy(at)hub(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] libpq + multiple connections ...
Date: 1999-11-29 07:48:40
Message-ID: Pine.BSF.4.21.9911290347330.69193-100000@thelab.hub.org (view raw or flat)
Thread:
Lists: pgsql-interfaces
On Mon, 29 Nov 1999, Tom Lane wrote:

> The Hermit Hacker <scrappy(at)hub(dot)org> forwards:
> > Hmm, sorta, I'm a bit troubled, I was trying to add an async connection
> > function to libpq and I stumbled across some problems.
> 
> Someone else was already working on that --- check the archives from
> a few months back.
> 
> > It seems that libpq makes use of some static variables, meaning i'm not
> > sure if it's safe to use libpq for multiple database connections.
> > What i'm refering to is:
> > postgresql-6.5.3/src/interfaces/libpq/fe-connect.c
> > line 79 has a structure that seems to be shared amongst the entire
> > library, am I likely to stumble upon more stuff that makes it somewhat
> > dangerous to have more than one active database connection in my program?
> 
> The PQconnectdb() function uses that static array, meaning that you can't
> safely run two PQconnectdb() calls in parallel.  But you can open two
> connections in sequence and then use them in parallel; and you can do
> the opens in parallel if you use one of the older, less-friendly
> connection-opening calls.  There aren't any other non-constant statics
> in libpq AFAIR.
> 
> The static array sucks, I agree, but I don't see any way to get rid of
> it without changing libpq's API for PQconnectdb() and PQconndefaults().
> Do we want to consider doing that (and breaking some apps) for 7.0?

IMHO...7.0 let's us pretty much go hog-wild as far as API changes are
concerned...if it is something that a) can be done and b) shoudl be
done...now is about the best time to do it...



Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org 
primary: scrappy(at)hub(dot)org           secondary: scrappy(at){freebsd|postgresql}.org 


In response to

pgsql-interfaces by date

Next:From: Michael MeskesDate: 1999-11-29 08:44:24
Subject: Re: [INTERFACES] ERROR: cannot find attribute 1 of relation pg_temp.460.0
Previous:From: Tom LaneDate: 1999-11-29 07:45:12
Subject: Re: [INTERFACES] libpq + multiple connections ...

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