Skip to content

Commit ce0b0fa

Browse files
committed
Doc: Adjust libpq docs about thread safety.
Describe the situation now that --disable-thread-safety is gone. Author: Heikki Linnakangas <hlinnaka@iki.fi> Discussion: https://postgr.es/m/CA%2BhUKGLtmexrpMtxBRLCVePqV_dtWG-ZsEbyPrYc%2BNBB2TkNsw%40mail.gmail.com
1 parent 68a4b58 commit ce0b0fa

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9236,14 +9236,28 @@ void PQinitSSL(int do_ssl);
92369236
</indexterm>
92379237

92389238
<para>
9239-
<application>libpq</application> is reentrant and thread-safe by default.
9240-
You might need to use special compiler command-line
9241-
options when you compile your application code. Refer to your
9242-
system's documentation for information about how to build
9243-
thread-enabled applications, or look in
9244-
<filename>src/Makefile.global</filename> for <literal>PTHREAD_CFLAGS</literal>
9245-
and <literal>PTHREAD_LIBS</literal>. This function allows the querying of
9246-
<application>libpq</application>'s thread-safe status:
9239+
As of version 17, <application>libpq</application> is always reentrant and thread-safe.
9240+
However, one restriction is that no two threads attempt to manipulate
9241+
the same <structname>PGconn</structname> object at the same time. In particular,
9242+
you cannot issue concurrent commands from different threads through
9243+
the same connection object. (If you need to run concurrent commands,
9244+
use multiple connections.)
9245+
</para>
9246+
9247+
<para>
9248+
<structname>PGresult</structname> objects are normally read-only after creation,
9249+
and so can be passed around freely between threads. However, if you use
9250+
any of the <structname>PGresult</structname>-modifying functions described in
9251+
<xref linkend="libpq-misc"/> or <xref linkend="libpq-events"/>, it's up
9252+
to you to avoid concurrent operations on the same <structname>PGresult</structname>,
9253+
too.
9254+
</para>
9255+
9256+
<para>
9257+
In earlier versions, <application>libpq</application> could be compiled
9258+
with or without thread support, depending on compiler options. This
9259+
function allows the querying of <application>libpq</application>'s
9260+
thread-safe status:
92479261
</para>
92489262

92499263
<variablelist>
@@ -9261,29 +9275,12 @@ int PQisthreadsafe();
92619275

92629276
<para>
92639277
Returns 1 if the <application>libpq</application> is thread-safe
9264-
and 0 if it is not.
9278+
and 0 if it is not. Always returns 1 on version 17 and above.
92659279
</para>
92669280
</listitem>
92679281
</varlistentry>
92689282
</variablelist>
92699283

9270-
<para>
9271-
One thread restriction is that no two threads attempt to manipulate
9272-
the same <structname>PGconn</structname> object at the same time. In particular,
9273-
you cannot issue concurrent commands from different threads through
9274-
the same connection object. (If you need to run concurrent commands,
9275-
use multiple connections.)
9276-
</para>
9277-
9278-
<para>
9279-
<structname>PGresult</structname> objects are normally read-only after creation,
9280-
and so can be passed around freely between threads. However, if you use
9281-
any of the <structname>PGresult</structname>-modifying functions described in
9282-
<xref linkend="libpq-misc"/> or <xref linkend="libpq-events"/>, it's up
9283-
to you to avoid concurrent operations on the same <structname>PGresult</structname>,
9284-
too.
9285-
</para>
9286-
92879284
<para>
92889285
The deprecated functions <xref linkend="libpq-PQrequestCancel"/> and
92899286
<xref linkend="libpq-PQoidStatus"/> are not thread-safe and should not be

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy