Thread: is libpq thread-safe?

is libpq thread-safe?

From
npat@kmp.forthnet.gr
Date:
A staight forward question:

   Is "libpq" thread-safe??

And an elaboration:

   I want to write a server that opens-up a number of connections
   to a PostgreSQL database, and then spawns threads handing a connection
   object (PGconn) to each thread, so that all the threads can
   perform data-base operations (queries) simultaneously. Each thread will
   use its own connection object. Will this work??

Tanks
npat.






Re: is libpq thread-safe?

From
Alfred Perlstein
Date:
* npat@kmp.forthnet.gr <npat@kmp.forthnet.gr> [001214 13:20] wrote:
> A staight forward question:
>
>    Is "libpq" thread-safe??
>
> And an elaboration:
>
>    I want to write a server that opens-up a number of connections
>    to a PostgreSQL database, and then spawns threads handing a connection
>    object (PGconn) to each thread, so that all the threads can
>    perform data-base operations (queries) simultaneously. Each thread will
>    use its own connection object. Will this work??

These are answered in the online docs.  Libpq is threadsafe with a
few exceptions, see the docs for functions you shouldn't call.

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."