Re: Is libpq thread-safe?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mike Mascari <mascarm(at)mascari(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Is libpq thread-safe?
Date: 2001-01-06 16:54:22
Message-ID: 17286.978800062@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mike Mascari <mascarm(at)mascari(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-01-06 16:59:57 Re: Sequence bug or feature?
Previous Message Ian deSouza 2001-01-06 16:54:19 Re: DROP SEQUENCE ?