Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 9b6cc37ce608401d44f6535a0c7cb777 > files > 487

postgresql11-docs-11.5-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>34.19. Behavior in Threaded Programs</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="libpq-ssl.html" title="34.18. SSL Support" /><link rel="next" href="libpq-build.html" title="34.20. Building libpq Programs" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">34.19. Behavior in Threaded Programs</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="libpq-ssl.html" title="34.18. SSL Support">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="libpq.html" title="Chapter 34. libpq - C Library">Up</a></td><th width="60%" align="center">Chapter 34. <span xmlns="http://www.w3.org/1999/xhtml" class="application">libpq</span> - C Library</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 11.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="libpq-build.html" title="34.20. Building libpq Programs">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="LIBPQ-THREADING"><div class="titlepage"><div><div><h2 class="title" style="clear: both">34.19. Behavior in Threaded Programs</h2></div></div></div><a id="id-1.7.3.26.2" class="indexterm"></a><p>
   <span class="application">libpq</span> is reentrant and thread-safe by default.
   You might need to use special compiler command-line
   options when you compile your application code.  Refer to your
   system's documentation for information about how to build
   thread-enabled applications, or look in
   <code class="filename">src/Makefile.global</code> for <code class="literal">PTHREAD_CFLAGS</code>
   and <code class="literal">PTHREAD_LIBS</code>.  This function allows the querying of
   <span class="application">libpq</span>'s thread-safe status:
  </p><div class="variablelist"><dl class="variablelist"><dt id="LIBPQ-PQISTHREADSAFE"><span class="term">
     <code class="function">PQisthreadsafe</code>
     <a id="id-1.7.3.26.4.1.1.2" class="indexterm"></a>
    </span></dt><dd><p>
      Returns the thread safety status of the
      <span class="application">libpq</span> library.
</p><pre class="synopsis">
int PQisthreadsafe();
</pre><p>
     </p><p>
      Returns 1 if the <span class="application">libpq</span> is thread-safe
      and 0 if it is not.
     </p></dd></dl></div><p>
   One thread restriction is that no two threads attempt to manipulate
   the same <code class="structname">PGconn</code> 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 multiple connections.)
  </p><p>
   <code class="structname">PGresult</code> objects are normally read-only after creation,
   and so can be passed around freely between threads.  However, if you use
   any of the <code class="structname">PGresult</code>-modifying functions described in
   <a class="xref" href="libpq-misc.html" title="34.11. Miscellaneous Functions">Section 34.11</a> or <a class="xref" href="libpq-events.html" title="34.13. Event System">Section 34.13</a>, it's up
   to you to avoid concurrent operations on the same <code class="structname">PGresult</code>,
   too.
  </p><p>
   The deprecated functions <code class="function">PQrequestCancel</code> and
   <code class="function">PQoidStatus</code> are not thread-safe and should not be
   used in multithread programs.  <code class="function">PQrequestCancel</code>
   can be replaced by <code class="function">PQcancel</code>.
   <code class="function">PQoidStatus</code> can be replaced by
   <code class="function">PQoidValue</code>.
  </p><p>
   If you are using Kerberos inside your application (in addition to inside
   <span class="application">libpq</span>), you will need to do locking around
   Kerberos calls because Kerberos functions are not thread-safe.  See
   function <code class="function">PQregisterThreadLock</code> in the
   <span class="application">libpq</span> source code for a way to do cooperative
   locking between <span class="application">libpq</span> and your application.
  </p><p>
   If you experience problems with threaded applications, run the program
   in <code class="filename">src/tools/thread</code> to see if your platform has
   thread-unsafe functions.  This program is run by
   <code class="filename">configure</code>, but for binary distributions your
   library might not match the library used to build the binaries.
  </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="libpq-ssl.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="libpq.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="libpq-build.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">34.18. SSL Support </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 34.20. Building <span class="application">libpq</span> Programs</td></tr></table></div></body></html>