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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [INTERFACES] libpq + multiple connections ...
Дата
Msg-id 13255.943861512@sss.pgh.pa.us
обсуждение исходный текст
Ответ на libpq + multiple connections ...  (The Hermit Hacker <scrappy@hub.org>)
Ответы Re: [INTERFACES] libpq + multiple connections ...  (The Hermit Hacker <scrappy@hub.org>)
Re: [INTERFACES] libpq + multiple connections ...  ("E.E. Mellor" <eem21@cam.ac.uk>)
Список pgsql-interfaces
The Hermit Hacker <scrappy@hub.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?
        regards, tom lane


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: libpq + multiple connections ...
Следующее
От: The Hermit Hacker
Дата:
Сообщение: Re: [INTERFACES] libpq + multiple connections ...