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.

38 lines
4.1KB

  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>46.5. Visibility of Data Changes</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="spi-spi-start-transaction.html" title="SPI_start_transaction" /><link rel="next" href="spi-examples.html" title="46.6. Examples" /></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">46.5. Visibility of Data Changes</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="spi-spi-start-transaction.html" title="SPI_start_transaction">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="spi.html" title="Chapter 46. Server Programming Interface">Up</a></td><th width="60%" align="center">Chapter 46. Server Programming Interface</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="spi-examples.html" title="46.6. Examples">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="SPI-VISIBILITY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">46.5. Visibility of Data Changes</h2></div></div></div><p>
  3. The following rules govern the visibility of data changes in
  4. functions that use SPI (or any other C function):
  5. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
  6. During the execution of an SQL command, any data changes made by
  7. the command are invisible to the command itself. For
  8. example, in:
  9. </p><pre class="programlisting">
  10. INSERT INTO a SELECT * FROM a;
  11. </pre><p>
  12. the inserted rows are invisible to the <code class="command">SELECT</code>
  13. part.
  14. </p></li><li class="listitem"><p>
  15. Changes made by a command C are visible to all commands that are
  16. started after C, no matter whether they are started inside C
  17. (during the execution of C) or after C is done.
  18. </p></li><li class="listitem"><p>
  19. Commands executed via SPI inside a function called by an SQL command
  20. (either an ordinary function or a trigger) follow one or the
  21. other of the above rules depending on the read/write flag passed
  22. to SPI. Commands executed in read-only mode follow the first
  23. rule: they cannot see changes of the calling command. Commands executed
  24. in read-write mode follow the second rule: they can see all changes made
  25. so far.
  26. </p></li><li class="listitem"><p>
  27. All standard procedural languages set the SPI read-write mode
  28. depending on the volatility attribute of the function. Commands of
  29. <code class="literal">STABLE</code> and <code class="literal">IMMUTABLE</code> functions are done in
  30. read-only mode, while commands of <code class="literal">VOLATILE</code> functions are
  31. done in read-write mode. While authors of C functions are able to
  32. violate this convention, it's unlikely to be a good idea to do so.
  33. </p></li></ul></div><p>
  34. </p><p>
  35. The next section contains an example that illustrates the
  36. application of these rules.
  37. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="spi-spi-start-transaction.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="spi.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="spi-examples.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">SPI_start_transaction </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 46.6. Examples</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1