Index: doc/src/sgml/libpq.sgml =================================================================== RCS file: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v retrieving revision 1.209 diff -c -c -r1.209 libpq.sgml *** doc/src/sgml/libpq.sgml 17 May 2006 21:50:54 -0000 1.209 --- doc/src/sgml/libpq.sgml 18 May 2006 18:15:30 -0000 *************** *** 4115,4125 **** system's documentation for information about how to build thread-enabled applications, or look in src/Makefile.global for PTHREAD_CFLAGS ! and PTHREAD_LIBS. ! 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, use --- 4115,4146 ---- system's documentation for information about how to build thread-enabled applications, or look in src/Makefile.global for PTHREAD_CFLAGS ! and PTHREAD_LIBS. This function allows the querying of ! libpq's thread-safe status: + + + PQisthreadsafePQisthreadsafe + ! Returns the thread safety status of the libpq ! library. ! ! int PQisthreadsafe(); ! ! ! ! ! Returns 1 if the libpq is thead-safe and ! 0 if it is not. ! ! ! ! ! ! ! One thread 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, use Index: src/interfaces/libpq/exports.txt =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/libpq/exports.txt,v retrieving revision 1.7 diff -c -c -r1.7 exports.txt *** src/interfaces/libpq/exports.txt 26 Dec 2005 14:58:05 -0000 1.7 --- src/interfaces/libpq/exports.txt 18 May 2006 18:15:51 -0000 *************** *** 126,128 **** --- 126,129 ---- PQinitSSL 124 PQregisterThreadLock 125 PQencryptPassword 126 + PQisthreadsafe 127 Index: src/interfaces/libpq/fe-exec.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v retrieving revision 1.182 diff -c -c -r1.182 fe-exec.c *** src/interfaces/libpq/fe-exec.c 14 Mar 2006 22:48:23 -0000 1.182 --- src/interfaces/libpq/fe-exec.c 18 May 2006 18:15:53 -0000 *************** *** 2326,2331 **** --- 2326,2343 ---- return pqIsnonblocking(conn); } + /* libpq is thread-safe? */ + int + PQisthreadsafe(void) + { + #ifdef ENABLE_THREAD_SAFETY + return true; + #else + return false; + #endif + } + + /* try to force data out, really only useful for non-blocking users */ int PQflush(PGconn *conn) Index: src/interfaces/libpq/libpq-fe.h =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/libpq/libpq-fe.h,v retrieving revision 1.127 diff -c -c -r1.127 libpq-fe.h *** src/interfaces/libpq/libpq-fe.h 27 Apr 2006 00:53:58 -0000 1.127 --- src/interfaces/libpq/libpq-fe.h 18 May 2006 18:15:54 -0000 *************** *** 366,371 **** --- 366,372 ---- /* Set blocking/nonblocking connection to the backend */ extern int PQsetnonblocking(PGconn *conn, int arg); extern int PQisnonblocking(const PGconn *conn); + extern int PQisthreadsafe(void); /* Force the write buffer to be written (or at least try) */ extern int PQflush(PGconn *conn);