PostgreSQL 7.4beta4 Documentation
Prev | Fast Backward | Chapter 27. libpq - C Library | Fast Forward | Next

# 27.12. Threading Behavior

libpq is thread-safe if the library is compiled using `configure`'s --enable-thread-safety command-line option. (In addition, you might need to use other threading command-line options to compile your client code.)

One restriction is that no two threads attempt to manipulate the same `PGconn` object at the same time. In particular, you cannot issue concurrent commands from different threads through the same connection object. (If you need to run concurrent commands, start up multiple connections.)

`PGresult` objects are read-only after creation, and so can be passed around freely between threads.

The deprecated functions `PQoidStatus` and `fe_setauthsvc` are not thread-safe and should not be used in multithread programs. `PQoidStatus` can be replaced by `PQoidValue`. There is no good reason to call `fe_setauthsvc` at all.

libpq applications that use the crypt authentication method rely on the crypt() operating system function, which is often not thread-safe. It is better to use the md5 method, which is thread-safe on all platforms.

Prev | Home | Next
The Password File | Up | Building libpq Programs