Skip to content

Latest commit

 

History

History
71 lines (51 loc) · 2.18 KB

show-savepoint-status.md

File metadata and controls

71 lines (51 loc) · 2.18 KB
title summary toc
SHOW SAVEPOINT STATUS
The SHOW SAVEPOINT STATUS statement lists the active savepoints in the current transaction.
true

The SHOW SAVEPOINT STATUS statement lists the active savepoints in the current transaction.

Required privileges

No privileges are required to create or show a savepoint. However, privileges are required for each statement within a transaction.

Synopsis

{% include {{ page.version.version }}/sql/diagrams/show_savepoint_status.html %}

Response

The following fields are returned for each savepoint.

Field Description
savepoint_name The name of the savepoint.
is_initial_savepoint Whether the savepoint is the outermost savepoint in the transaction.

Example

First, open a transaction using BEGIN, and create a nested transaction using a savepoint:

{% include copy-clipboard.html %}

> BEGIN;
SAVEPOINT foo;

Next, use the SHOW SAVEPOINT STATUS statement to list the active savepoints in the current nested transaction.

{% include copy-clipboard.html %}

> SHOW SAVEPOINT STATUS;
  savepoint_name | is_initial_savepoint
-----------------+-----------------------
  foo            |        true
(1 row)

Currently, there is only one savepoint.

We can commit this nested transaction by issuing the RELEASE SAVEPOINT statement. Then, we clear the connection for the next transaction by issuing a COMMIT statement.

{% include copy-clipboard.html %}

> RELEASE SAVEPOINT foo;
COMMIT;

If we did not want to commit this nested transaction, but restart it instead, we would have issued a ROLLBACK TO SAVEPOINT.

See also