mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Add PQisthreadsafe() to libpq, to allow library applications to query
the thread-safety status of the library.
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.210 2006/05/21 20:19:23 tgl Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.211 2006/05/23 22:13:19 momjian Exp $ -->
|
||||||
|
|
||||||
<chapter id="libpq">
|
<chapter id="libpq">
|
||||||
<title><application>libpq</application> - C Library</title>
|
<title><application>libpq</application> - C Library</title>
|
||||||
@ -4196,11 +4196,32 @@ options when you compile your application code. Refer to your
|
|||||||
system's documentation for information about how to build
|
system's documentation for information about how to build
|
||||||
thread-enabled applications, or look in
|
thread-enabled applications, or look in
|
||||||
<filename>src/Makefile.global</filename> for <literal>PTHREAD_CFLAGS</>
|
<filename>src/Makefile.global</filename> for <literal>PTHREAD_CFLAGS</>
|
||||||
and <literal>PTHREAD_LIBS</>.
|
and <literal>PTHREAD_LIBS</>. This function allows the querying of
|
||||||
|
<application>libpq</application>'s thread-safe status:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><function>PQisthreadsafe</function><indexterm><primary>PQisthreadsafe</></></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Returns the thread safety status of the <application>libpq</application>
|
||||||
|
library.
|
||||||
|
<synopsis>
|
||||||
|
int PQisthreadsafe();
|
||||||
|
</synopsis>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
One restriction is that no two threads attempt to manipulate the same
|
Returns 1 if the <application>libpq</application> is thead-safe and
|
||||||
|
0 if it is not.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
One thread restriction is that no two threads attempt to manipulate the same
|
||||||
<structname>PGconn</> object at the same time. In particular, you cannot
|
<structname>PGconn</> object at the same time. In particular, you cannot
|
||||||
issue concurrent commands from different threads through the same
|
issue concurrent commands from different threads through the same
|
||||||
connection object. (If you need to run concurrent commands, use
|
connection object. (If you need to run concurrent commands, use
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $PostgreSQL: pgsql/src/interfaces/libpq/exports.txt,v 1.8 2006/05/21 20:19:23 tgl Exp $
|
# $PostgreSQL: pgsql/src/interfaces/libpq/exports.txt,v 1.9 2006/05/23 22:13:19 momjian Exp $
|
||||||
# Functions to be exported by libpq DLLs
|
# Functions to be exported by libpq DLLs
|
||||||
PQconnectdb 1
|
PQconnectdb 1
|
||||||
PQsetdbLogin 2
|
PQsetdbLogin 2
|
||||||
@ -128,3 +128,5 @@ PQregisterThreadLock 125
|
|||||||
PQescapeStringConn 126
|
PQescapeStringConn 126
|
||||||
PQescapeByteaConn 127
|
PQescapeByteaConn 127
|
||||||
PQencryptPassword 128
|
PQencryptPassword 128
|
||||||
|
PQisthreadsafe 129
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.183 2006/05/21 20:19:23 tgl Exp $
|
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.184 2006/05/23 22:13:19 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -2343,6 +2343,18 @@ PQisnonblocking(const PGconn *conn)
|
|||||||
return pqIsnonblocking(conn);
|
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 */
|
/* try to force data out, really only useful for non-blocking users */
|
||||||
int
|
int
|
||||||
PQflush(PGconn *conn)
|
PQflush(PGconn *conn)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.128 2006/05/21 20:19:23 tgl Exp $
|
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.129 2006/05/23 22:13:19 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -366,6 +366,7 @@ extern int PQendcopy(PGconn *conn);
|
|||||||
/* Set blocking/nonblocking connection to the backend */
|
/* Set blocking/nonblocking connection to the backend */
|
||||||
extern int PQsetnonblocking(PGconn *conn, int arg);
|
extern int PQsetnonblocking(PGconn *conn, int arg);
|
||||||
extern int PQisnonblocking(const PGconn *conn);
|
extern int PQisnonblocking(const PGconn *conn);
|
||||||
|
extern int PQisthreadsafe(void);
|
||||||
|
|
||||||
/* Force the write buffer to be written (or at least try) */
|
/* Force the write buffer to be written (or at least try) */
|
||||||
extern int PQflush(PGconn *conn);
|
extern int PQflush(PGconn *conn);
|
||||||
|
Reference in New Issue
Block a user