Re: Is libpq thread-safe? - Mailing list pgsql-general

From Tom Lane
Subject Re: Is libpq thread-safe?
Date
Msg-id 17286.978800062@sss.pgh.pa.us
Whole thread Raw
In response to Is libpq thread-safe?  (Mike Mascari <mascarm@mascari.com>)
List pgsql-general
Mike Mascari <mascarm@mascari.com> writes:
> Can I assume that libpq as of version 7 is now thread-safe?

The SSL option seems to have a static variable, as do the Kerberos auth
methods (both 4 and 5).  Not sure what the implications are for thread
safeness; you might have to serialize connection opening when using
these options.

PQoidStatus is not thread-safe (as documented, but it's deprecated
anyway).  I also see a completely unnecessary static variable in
PQprint, which I shall get rid of today.

Other than that, I don't see any static variables in libpq.  This is not
really the same thing as thread-safeness; in particular, if you have
multiple threads accessing the same PQconn object, it's up to you to
interlock them.  But you could have multiple threads each using its own
PQconn.  You could also have one thread making the queries (touching
PQconn) and then hand off PQresults to other threads for processing.

            regards, tom lane

pgsql-general by date:

Previous
From: Frank Joerdens
Date:
Subject: Re: PHP and PostgreSQL
Next
From: Tom Lane
Date:
Subject: Re: Sequence bug or feature?