Updated on 2024-05-07 GMT+08:00

COMMIT PREPARED

Description

Commits a prepared two-phase transaction. This function is for internal use only. You are advised not to use it.

Precautions

  • The function is only available in maintenance mode (when GUC parameter xc_maintenance_mode is on). Exercise caution when enabling the mode. It is used by maintenance engineers for troubleshooting. Common users should not use the mode.
  • Only the transaction creators or system administrators can run the COMMIT PREPARED command. The creation and commit operations must be in different sessions.
  • The transaction function is maintained automatically by the database, and should be not visible to users.

Syntax

1
COMMIT PREPARED transaction_id [ WITH commit_sequence_number ];

Parameters

  • transaction_id

    Specifies the identifier of the transaction to be committed. The identifier must be different from those for current prepared transactions.

  • commit_sequence_number

    Specifies the sequence number of the transaction to be committed. It is a 64-bit, incremental, unsigned number.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
-- Start.
gaussdb=# BEGIN;

-- Prepare a transaction whose identifier is trans_test.
gaussdb=# PREPARE TRANSACTION 'trans_test';

-- Create a table.
gaussdb=# CREATE TABLE item1(id int);

--Commit the transaction whose identifier is trans_test.
gaussdb=# COMMIT PREPARED 'trans_test';

-- Delete the table.
gaussdb=# DROP TABLE item1;