gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
8.7KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!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>33.10. Control Functions</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 V1.79.1" /><link rel="prev" href="libpq-copy.html" title="33.9. Functions Associated with the COPY Command" /><link rel="next" href="libpq-misc.html" title="33.11. Miscellaneous Functions" /></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">33.10. Control Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="libpq-copy.html" title="33.9. Functions Associated with the COPY Command">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="libpq.html" title="Chapter 33. libpq - C Library">Up</a></td><th width="60%" align="center">Chapter 33. <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 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="libpq-misc.html" title="33.11. Miscellaneous Functions">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="LIBPQ-CONTROL"><div class="titlepage"><div><div><h2 class="title" style="clear: both">33.10. Control Functions</h2></div></div></div><p>
  3. These functions control miscellaneous details of <span class="application">libpq</span>'s
  4. behavior.
  5. </p><div class="variablelist"><dl class="variablelist"><dt id="LIBPQ-PQCLIENTENCODING"><span class="term">
  6. <code class="function">PQclientEncoding</code>
  7. <a id="id-1.7.3.17.3.1.1.2" class="indexterm"></a>
  8. </span></dt><dd><p>
  9. Returns the client encoding.
  10. </p><pre class="synopsis">
  11. int PQclientEncoding(const PGconn *<em class="replaceable"><code>conn</code></em>);
  12. </pre><p>
  13. Note that it returns the encoding ID, not a symbolic string
  14. such as <code class="literal">EUC_JP</code>. If unsuccessful, it returns -1.
  15. To convert an encoding ID to an encoding name, you
  16. can use:
  17. </p><pre class="synopsis">
  18. char *pg_encoding_to_char(int <em class="replaceable"><code>encoding_id</code></em>);
  19. </pre><p>
  20. </p></dd><dt id="LIBPQ-PQSETCLIENTENCODING"><span class="term">
  21. <code class="function">PQsetClientEncoding</code>
  22. <a id="id-1.7.3.17.3.2.1.2" class="indexterm"></a>
  23. </span></dt><dd><p>
  24. Sets the client encoding.
  25. </p><pre class="synopsis">
  26. int PQsetClientEncoding(PGconn *<em class="replaceable"><code>conn</code></em>, const char *<em class="replaceable"><code>encoding</code></em>);
  27. </pre><p>
  28. <em class="replaceable"><code>conn</code></em> is a connection to the server,
  29. and <em class="replaceable"><code>encoding</code></em> is the encoding you want to
  30. use. If the function successfully sets the encoding, it returns 0,
  31. otherwise -1. The current encoding for this connection can be
  32. determined by using <code class="function">PQclientEncoding</code>.
  33. </p></dd><dt id="LIBPQ-PQSETERRORVERBOSITY"><span class="term">
  34. <code class="function">PQsetErrorVerbosity</code>
  35. <a id="id-1.7.3.17.3.3.1.2" class="indexterm"></a>
  36. </span></dt><dd><p>
  37. Determines the verbosity of messages returned by
  38. <code class="function">PQerrorMessage</code> and <code class="function">PQresultErrorMessage</code>.
  39. </p><pre class="synopsis">
  40. typedef enum
  41. {
  42. PQERRORS_TERSE,
  43. PQERRORS_DEFAULT,
  44. PQERRORS_VERBOSE,
  45. PQERRORS_SQLSTATE
  46. } PGVerbosity;
  47. PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
  48. </pre><p>
  49. <code class="function">PQsetErrorVerbosity</code> sets the verbosity mode,
  50. returning the connection's previous setting.
  51. In <em class="firstterm">TERSE</em> mode, returned messages include
  52. severity, primary text, and position only; this will normally fit on a
  53. single line. The <em class="firstterm">DEFAULT</em> mode produces messages
  54. that include the above plus any detail, hint, or context fields (these
  55. might span multiple lines). The <em class="firstterm">VERBOSE</em> mode
  56. includes all available fields. The <em class="firstterm">SQLSTATE</em>
  57. mode includes only the error severity and the <code class="symbol">SQLSTATE</code>
  58. error code, if one is available (if not, the output is like
  59. <em class="firstterm">TERSE</em> mode).
  60. </p><p>
  61. Changing the verbosity setting does not affect the messages available
  62. from already-existing <code class="structname">PGresult</code> objects, only
  63. subsequently-created ones.
  64. (But see <code class="function">PQresultVerboseErrorMessage</code> if you
  65. want to print a previous error with a different verbosity.)
  66. </p></dd><dt id="LIBPQ-PQSETERRORCONTEXTVISIBILITY"><span class="term">
  67. <code class="function">PQsetErrorContextVisibility</code>
  68. <a id="id-1.7.3.17.3.4.1.2" class="indexterm"></a>
  69. </span></dt><dd><p>
  70. Determines the handling of <code class="literal">CONTEXT</code> fields in messages
  71. returned by <code class="function">PQerrorMessage</code>
  72. and <code class="function">PQresultErrorMessage</code>.
  73. </p><pre class="synopsis">
  74. typedef enum
  75. {
  76. PQSHOW_CONTEXT_NEVER,
  77. PQSHOW_CONTEXT_ERRORS,
  78. PQSHOW_CONTEXT_ALWAYS
  79. } PGContextVisibility;
  80. PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context);
  81. </pre><p>
  82. <code class="function">PQsetErrorContextVisibility</code> sets the context display mode,
  83. returning the connection's previous setting. This mode controls
  84. whether the <code class="literal">CONTEXT</code> field is included in messages.
  85. The <em class="firstterm">NEVER</em> mode
  86. never includes <code class="literal">CONTEXT</code>, while <em class="firstterm">ALWAYS</em> always
  87. includes it if available. In <em class="firstterm">ERRORS</em> mode (the
  88. default), <code class="literal">CONTEXT</code> fields are included only in error
  89. messages, not in notices and warnings.
  90. (However, if the verbosity setting is <em class="firstterm">TERSE</em>
  91. or <em class="firstterm">SQLSTATE</em>, <code class="literal">CONTEXT</code> fields
  92. are omitted regardless of the context display mode.)
  93. </p><p>
  94. Changing this mode does not
  95. affect the messages available from
  96. already-existing <code class="structname">PGresult</code> objects, only
  97. subsequently-created ones.
  98. (But see <code class="function">PQresultVerboseErrorMessage</code> if you
  99. want to print a previous error with a different display mode.)
  100. </p></dd><dt id="LIBPQ-PQTRACE"><span class="term">
  101. <code class="function">PQtrace</code>
  102. <a id="id-1.7.3.17.3.5.1.2" class="indexterm"></a>
  103. </span></dt><dd><p>
  104. Enables tracing of the client/server communication to a debugging file stream.
  105. </p><pre class="synopsis">
  106. void PQtrace(PGconn *conn, FILE *stream);
  107. </pre><p>
  108. </p><div class="note"><h3 class="title">Note</h3><p>
  109. On Windows, if the <span class="application">libpq</span> library and an application are
  110. compiled with different flags, this function call will crash the
  111. application because the internal representation of the <code class="literal">FILE</code>
  112. pointers differ. Specifically, multithreaded/single-threaded,
  113. release/debug, and static/dynamic flags should be the same for the
  114. library and all applications using that library.
  115. </p></div></dd><dt id="LIBPQ-PQUNTRACE"><span class="term">
  116. <code class="function">PQuntrace</code>
  117. <a id="id-1.7.3.17.3.6.1.2" class="indexterm"></a>
  118. </span></dt><dd><p>
  119. Disables tracing started by <code class="function">PQtrace</code>.
  120. </p><pre class="synopsis">
  121. void PQuntrace(PGconn *conn);
  122. </pre><p>
  123. </p></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="libpq-copy.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-misc.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">33.9. Functions Associated with the <code class="command">COPY</code> Command </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 33.11. Miscellaneous Functions</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1