Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
sql-release-savepoint.html66 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>RELEASE SAVEPOINT</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="sql-reindex.html" title="REINDEX" /><link rel="next" href="sql-reset.html" title="RESET" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">RELEASE SAVEPOINT</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-reindex.html" title="REINDEX">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</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="sql-reset.html" title="RESET">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-RELEASE-SAVEPOINT"><div class="titlepage"></div><a id="id-1.9.3.164.1" class="indexterm"></a><a id="id-1.9.3.164.2" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">RELEASE SAVEPOINT</span></h2><p>RELEASE SAVEPOINT — release a previously defined savepoint</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">3RELEASE [ SAVEPOINT ] <em class="replaceable"><code>savepoint_name</code></em>4</pre></div><div class="refsect1" id="id-1.9.3.164.6"><h2>Description</h2><p>5   <code class="command">RELEASE SAVEPOINT</code> releases the named savepoint and6   all active savepoints that were created after the named savepoint,7   and frees their resources.  All changes made since the creation of8   the savepoint that didn't already get rolled back are merged into9   the transaction or savepoint that was active when the named savepoint10   was created.  Changes made after <code class="command">RELEASE SAVEPOINT</code>11   will also be part of this active transaction or savepoint.12  </p></div><div class="refsect1" id="id-1.9.3.164.7"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>savepoint_name</code></em></span></dt><dd><p>13      The name of the savepoint to release.14     </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.164.8"><h2>Notes</h2><p>15   Specifying a savepoint name that was not previously defined is an error.16  </p><p>17   It is not possible to release a savepoint when the transaction is in18   an aborted state;  to do that, use <a class="xref" href="sql-rollback-to.html" title="ROLLBACK TO SAVEPOINT"><span class="refentrytitle">ROLLBACK TO SAVEPOINT</span></a>.19  </p><p>20   If multiple savepoints have the same name, only the most recently defined21   unreleased one is released.  Repeated commands will release progressively22   older savepoints.23  </p></div><div class="refsect1" id="id-1.9.3.164.9"><h2>Examples</h2><p>24   To establish and later release a savepoint:25</p><pre class="programlisting">26BEGIN;27    INSERT INTO table1 VALUES (3);28    SAVEPOINT my_savepoint;29    INSERT INTO table1 VALUES (4);30    RELEASE SAVEPOINT my_savepoint;31COMMIT;32</pre><p>33   The above transaction will insert both 3 and 4.34  </p><p>35   A more complex example with multiple nested subtransactions:36</p><pre class="programlisting">37BEGIN;38    INSERT INTO table1 VALUES (1);39    SAVEPOINT sp1;40    INSERT INTO table1 VALUES (2);41    SAVEPOINT sp2;42    INSERT INTO table1 VALUES (3);43    RELEASE SAVEPOINT sp2;44    INSERT INTO table1 VALUES (4))); -- generates an error45</pre><p>46   In this example, the application requests the release of the savepoint47   <code class="literal">sp2</code>, which inserted 3.  This changes the insert's48   transaction context to <code class="literal">sp1</code>.  When the statement49   attempting to insert value 4 generates an error, the insertion of 2 and50   4 are lost because they are in the same, now-rolled back savepoint,51   and value 3 is in the same transaction context.  The application can52   now only choose one of these two commands, since all other commands53   will be ignored:54</p><pre class="programlisting">55   ROLLBACK;56   ROLLBACK TO SAVEPOINT sp1;57</pre><p>58   Choosing <code class="command">ROLLBACK</code> will abort everything, including59   value 1, whereas <code class="command">ROLLBACK TO SAVEPOINT sp1</code> will retain60   value 1 and allow the transaction to continue.61  </p></div><div class="refsect1" id="id-1.9.3.164.10"><h2>Compatibility</h2><p>62   This command conforms to the <acronym class="acronym">SQL</acronym> standard.  The standard63   specifies that the key word <code class="literal">SAVEPOINT</code> is64   mandatory, but <span class="productname">PostgreSQL</span> allows it to65   be omitted.66  </p></div><div class="refsect1" id="id-1.9.3.164.11"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-begin.html" title="BEGIN"><span class="refentrytitle">BEGIN</span></a>, <a class="xref" href="sql-commit.html" title="COMMIT"><span class="refentrytitle">COMMIT</span></a>, <a class="xref" href="sql-rollback.html" title="ROLLBACK"><span class="refentrytitle">ROLLBACK</span></a>, <a class="xref" href="sql-rollback-to.html" title="ROLLBACK TO SAVEPOINT"><span class="refentrytitle">ROLLBACK TO SAVEPOINT</span></a>, <a class="xref" href="sql-savepoint.html" title="SAVEPOINT"><span class="refentrytitle">SAVEPOINT</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-reindex.html" title="REINDEX">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-reset.html" title="RESET">Next</a></td></tr><tr><td width="40%" align="left" valign="top">REINDEX </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"> RESET</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai