Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
spi-visibility.html38 linesDownload Raw Back to html
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>47.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 Vsnapshot" /><link rel="prev" href="spi-spi-start-transaction.html" title="SPI_start_transaction" /><link rel="next" href="spi-examples.html" title="47.6. Examples" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">47.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 47. Server Programming Interface">Up</a></td><th width="60%" align="center">Chapter 47. Server Programming Interface</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="spi-examples.html" title="47.6. Examples">Next</a></td></tr></table><hr /></div><div class="sect1" id="SPI-VISIBILITY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">47.5. Visibility of Data Changes <a href="#SPI-VISIBILITY" class="id_link">#</a></h2></div></div></div><p>3   The following rules govern the visibility of data changes in4   functions that use SPI (or any other C function):5 6   </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>7      During the execution of an SQL command, any data changes made by8      the command are invisible to the command itself.  For9      example, in:10</p><pre class="programlisting">11INSERT INTO a SELECT * FROM a;12</pre><p>13      the inserted rows are invisible to the <code class="command">SELECT</code>14      part.15     </p></li><li class="listitem"><p>16      Changes made by a command C are visible to all commands that are17      started after C, no matter whether they are started inside C18      (during the execution of C) or after C is done.19     </p></li><li class="listitem"><p>20      Commands executed via SPI inside a function called by an SQL command21      (either an ordinary function or a trigger) follow one or the22      other of the above rules depending on the read/write flag passed23      to SPI.  Commands executed in read-only mode follow the first24      rule: they cannot see changes of the calling command.  Commands executed25      in read-write mode follow the second rule: they can see all changes made26      so far.27     </p></li><li class="listitem"><p>28      All standard procedural languages set the SPI read-write mode29      depending on the volatility attribute of the function.  Commands of30      <code class="literal">STABLE</code> and <code class="literal">IMMUTABLE</code> functions are done in31      read-only mode, while commands of <code class="literal">VOLATILE</code> functions are32      done in read-write mode.  While authors of C functions are able to33      violate this convention, it's unlikely to be a good idea to do so.34     </p></li></ul></div><p>35  </p><p>36   The next section contains an example that illustrates the37   application of these rules.38  </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" title="SPI_start_transaction">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="spi.html" title="Chapter 47. Server Programming Interface">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="spi-examples.html" title="47.6. Examples">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" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 47.6. Examples</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai