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.

46 lines
5.8KB

  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>35.11. Library 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="ecpg-process.html" title="35.10. Processing Embedded SQL Programs" /><link rel="next" href="ecpg-lo.html" title="35.12. Large Objects" /></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">35.11. Library Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg-process.html" title="35.10. Processing Embedded SQL Programs">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ecpg.html" title="Chapter 35. ECPG - Embedded SQL in C">Up</a></td><th width="60%" align="center">Chapter 35. <span xmlns="http://www.w3.org/1999/xhtml" class="application">ECPG</span> - Embedded <acronym xmlns="http://www.w3.org/1999/xhtml" class="acronym">SQL</acronym> in C</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="ecpg-lo.html" title="35.12. Large Objects">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="ECPG-LIBRARY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">35.11. Library Functions</h2></div></div></div><p>
  3. The <code class="filename">libecpg</code> library primarily contains
  4. <span class="quote">“<span class="quote">hidden</span>”</span> functions that are used to implement the
  5. functionality expressed by the embedded SQL commands. But there
  6. are some functions that can usefully be called directly. Note that
  7. this makes your code unportable.
  8. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
  9. <code class="function">ECPGdebug(int <em class="replaceable"><code>on</code></em>, FILE
  10. *<em class="replaceable"><code>stream</code></em>)</code> turns on debug
  11. logging if called with the first argument non-zero. Debug logging
  12. is done on <em class="replaceable"><code>stream</code></em>. The log contains
  13. all <acronym class="acronym">SQL</acronym> statements with all the input
  14. variables inserted, and the results from the
  15. <span class="productname">PostgreSQL</span> server. This can be very
  16. useful when searching for errors in your <acronym class="acronym">SQL</acronym>
  17. statements.
  18. </p><div class="note"><h3 class="title">Note</h3><p>
  19. On Windows, if the <span class="application">ecpg</span> libraries and an application are
  20. compiled with different flags, this function call will crash the
  21. application because the internal representation of the
  22. <code class="literal">FILE</code> pointers differ. Specifically,
  23. multithreaded/single-threaded, release/debug, and static/dynamic
  24. flags should be the same for the library and all applications using
  25. that library.
  26. </p></div></li><li class="listitem"><p>
  27. <code class="function">ECPGget_PGconn(const char *<em class="replaceable"><code>connection_name</code></em>)
  28. </code> returns the library database connection handle identified by the given name.
  29. If <em class="replaceable"><code>connection_name</code></em> is set to <code class="literal">NULL</code>, the current
  30. connection handle is returned. If no connection handle can be identified, the function returns
  31. <code class="literal">NULL</code>. The returned connection handle can be used to call any other functions
  32. from <span class="application">libpq</span>, if necessary.
  33. </p><div class="note"><h3 class="title">Note</h3><p>
  34. It is a bad idea to manipulate database connection handles made from <span class="application">ecpg</span> directly
  35. with <span class="application">libpq</span> routines.
  36. </p></div></li><li class="listitem"><p>
  37. <code class="function">ECPGtransactionStatus(const char *<em class="replaceable"><code>connection_name</code></em>)</code>
  38. returns the current transaction status of the given connection identified by <em class="replaceable"><code>connection_name</code></em>.
  39. See <a class="xref" href="libpq-status.html" title="33.2. Connection Status Functions">Section 33.2</a> and libpq's <code class="function">PQtransactionStatus()</code> for details about the returned status codes.
  40. </p></li><li class="listitem"><p>
  41. <code class="function">ECPGstatus(int <em class="replaceable"><code>lineno</code></em>,
  42. const char* <em class="replaceable"><code>connection_name</code></em>)</code>
  43. returns true if you are connected to a database and false if not.
  44. <em class="replaceable"><code>connection_name</code></em> can be <code class="literal">NULL</code>
  45. if a single connection is being used.
  46. </p></li></ul></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ecpg-process.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ecpg.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-lo.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">35.10. Processing Embedded SQL Programs </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 35.12. Large Objects</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1