Database Transaction

Function introduction

A Database Transaction is a sequence of database operations that access and possibly manipulate a variety of data. These operations are either all performed or none performed, and are an indivisible unit of work. Database Transactions have four basic characteristics:

  • Atomicity: All operations in a transaction are indivisible in the database, either all are performed or none are performed.
  • Consistency: The Result of several transactions executed in parallel must be consistent with the result of a sequential serial execution.
  • Isolation: The execution of a transaction is not interfered by other transactions, and the intermediate results of the execution of a transaction must be transparent to other transactions.
  • Persistence: For any committed transaction, the system must ensure that the changes made to the database by the transaction are not lost, even if the database fails.

Based on the four features of Database Transaction, for example, when importing data from external to GIS database, the transaction can ensure the complete import of data and avoid data corruption or inconsistency caused by failure in the middle (such as sudden power failure, operating system crash, etc.).

In SuperMap iDesktopX, Database Transaction is used as follows:

  • PostGISDatabase-type Datasource is supported.
  • Support the Start Transaction of the user who uses and Creates Permissions for Datasource, but the operation permission for Dataset is restricted by User permissions .
  • Supported Dataset Types exclude: Image/Raster Dataset, Vector Dataset with Pyramid, Mosaic Dataset, Register Version Dataset.

This article mainly introduces how to use Database Transaction, including Start Transaction, operating on the database, rolling back or committing data to end the transaction operation.

  • Start Transaction: Once enabled, you can perform transaction operations on the database.
  • Commit Transaction: Commit all operations after the Start Transaction to the database, and permanently save the update results to the database.
  • Rollback Transaction: Removes all operations after the Start Transaction. Changes to the database are not saved.

Starting with SuperMap iDesktopX 11i (2024), Database Transaction functionality is available.

Operating instructions

  1. Open Database Datasource and Start Transaction. There are two ways to Start Transaction:
    • Method 1: Click the Data tab-& gt Database Transaction Grouping-& gt Start Transaction button. Check the Datasource to be managed in the Start Transaction dialog. The button is available when there is a Datasource in the Current Workspace that does not have a Start Transaction.
    • Method 2: Right click in Workspace Manager and select Database-type Datasource- > Database Transaction-> for Start Transaction management. Start Transaction button .
    After a DatasourceStart Transaction is performed

    in any of the above ways, a blue dot appears on the Datasource node icon to indicate that the Datasource is in a transaction. If the Datasource is disconnected from the database, the transaction operation will be invalidated and automatically restored to the state before the Start Transaction.

    When multiple users start Transaction at the same time, they may be affected by other transactions. Therefore, different transaction locks are provided on the Dataset to ensure that the Database Transaction meets its four basic characteristics.

    • There are other transaction locks: the Dataset is being queried, edited, or analyzed by another user.
    • Current transaction lock: The current user queries, edits, or analyzes the Dataset first. Other users may operate the Dataset at the same time.
    • No transaction lock: No user queries, edits, or analyzes the Dataset.

    Available through DatasetContext Menu- Manage- Transaction Lock View the Transaction Lock Status of the Dataset. The impact of different Transaction Lock Status on other functions

    is as follows: Delete Modification again Register Version is by the transaction Register Version is by transactions after registration
    Function point There are other transaction locks Current transaction lock No transaction lock
    Create Dataset Not affected by transactions, commit directly to the library
    Modify Dataset Name, Modify Field Alias Not affected by transactions, commit directly to the library
    Import External Data as New Dataset

    Not affected by transactions.

    • If Failed Import, the DatasetTable Structure is directly in the Save to Library, the data record is saved in the transaction, and the Save to Library is after the Commit Transaction.
    • If Create Spatial Index is not checked when Import Dataset, the imported record will be saved in the current transaction. A Commit/Rollback Transaction is required to save or delete all records that were not committed during the import process and before the import. The DatasetTable Structure is directly in the Save to Library and is not subject to the transaction image.
    • If Create Spatial Index is checked during Import Dataset, the current transaction will be committed by default, and Start Transaction will be started automatically after Import Dataset. You cannot roll back all records that were not committed during the import process and before the import.
    Delete Dataset Not supported Not supported directly and commit to the library
    Object Editing (including spaces, Attributes)
      Non-identical objects
    • can be edited When
    • editing the same object, the first user will lock the object, and other users cannot edit it (editing will stay for 5 seconds, and the operation will be rolled back. At the same time, the Output Window prompts, such as "Dataset NewRegion failed to submit data." Failure reason: The record to be modified may be edited by other transactions. )
      Non-identical objects
    • can be edited When
    • editing the same object, the first user will lock the object, and other users cannot edit it (editing will stay for 5 seconds, and the operation will be rolled back. At the same time, the Output Window prompts, such as "Dataset NewRegion failed to submit data." Failure reason: The record to be modified may be edited by other transactions. )
    Editable All Objects
    Involves Table Structure operations, including Import Data (Add Fields), etc. is not supported The current transaction is submitted by default, and then the Table Structure is edited (including Creating Field, Delete Field, Modify Type, Modify field default value, and Modify field name). Edit content is directly submitted to the library, and Start Transaction Directly submit for warehousing, including Creating Field, Delete Field, Modify Type, Modify Field default value, and Modify Field name editing.
    Analysis
    • No new/Delete Field, Analyst Result saved to current transaction
    • New/Delete Field, Analysis failed
    • No new/Delete Field, Analyst Result saved to current transaction
    • New/Delete Field
    • is available, the current transaction is committed by default, the field is modified to Save to Library directly, and the new transaction is restarted. Save to Library the action before the analysis, and save the subsequent actions in a new
    • transaction
    • No new/Delete Field, Analyst Result saved to current transaction
    • New/Delete Field
    • is available. The newly created/deleted field is directly saved in the Save to Library. The Analyst Result is saved in the current
    • transaction
    Register Version Not supported supported. The current transaction needs to be submitted first. After registration, it is not affected supported and is not affected
  2. After the transaction operation is completed, all changes to the database can be undone through Rollback Transaction, or all changes to the database can be saved through Commit Transaction, thus ending the transaction. The following two functional operation modes are provided:
    • Method 1: Click the Data tab-& gt Database Transaction Grouping-& gt Rollback Transaction/ Commit Transaction, check the Datasource to end the transaction in the pop-up dialog box.
    • Method 2: Right click in Workspace Manager and select Datasource-& gt Database Transaction-& gt where rollback/Commit Transaction is required. Rollback Transaction/Commit Transaction button.

Related topics

Overview of Database User Management

Create Database User

Version Control overview