TRANSACTION

TRANSACTION

#Overview

name: TRANSACTION

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of TRANSACTION is to manage database transactions in various Unreal Engine 5 subsystems that use SQLite databases. It is primarily used for ensuring data integrity and consistency when performing multiple database operations that need to be treated as a single unit of work.

This setting variable is relied upon by several Unreal Engine subsystems and plugins:

  1. Concert Sync Core Plugin: Used in the ConcertSyncSessionDatabase for managing synchronization data.
  2. Asset Search Plugin: Utilized in both AssetSearchDatabase and FileInfoDatabase for managing asset and file information.
  3. UnrealEd Module: Referenced in the EditorServer for transaction tracking and control.

The value of this variable is not directly set as a configuration option. Instead, it is used as a command or keyword to trigger transaction-related operations in the database systems.

The TRANSACTION keyword interacts with three main database operations:

  1. BEGIN TRANSACTION: Starts a new transaction.
  2. COMMIT TRANSACTION: Finalizes and saves the changes made during the transaction.
  3. ROLLBACK TRANSACTION: Discards all changes made during the transaction.

Developers must be aware of the following when using this variable:

  1. Transactions are crucial for maintaining data consistency, especially when performing multiple related database operations.
  2. Proper error handling is essential to ensure that transactions are either committed or rolled back appropriately.
  3. Long-running transactions can impact database performance and concurrency.

Best practices when using this variable include:

  1. Keep transactions as short as possible to minimize lock contention.
  2. Always ensure that transactions are properly closed (either committed or rolled back) to prevent database locks.
  3. Use transactions when performing multiple related database operations that need to be treated as a single unit of work.
  4. Implement proper error handling to manage transaction states in case of unexpected errors or exceptions.
  5. Be mindful of the performance impact of transactions, especially in performance-critical parts of the engine or game.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Developer/Concert/ConcertSync/ConcertSyncCore/Source/ConcertSyncCore/Private/ConcertSyncSessionDatabase.cpp:654

Scope: file

Source code excerpt:


	/** Begin a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FBeginTransaction, "BEGIN TRANSACTION;");
	FBeginTransaction Statement_BeginTransaction;
	bool BeginTransaction()
	{
		return Statement_BeginTransaction.Execute();
	}

	/** Commit a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FCommitTransaction, "COMMIT TRANSACTION;");
	FCommitTransaction Statement_CommitTransaction;
	bool CommitTransaction()
	{
		return Statement_CommitTransaction.Execute();
	}

	/** Rollback a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FRollbackTransaction, "ROLLBACK TRANSACTION;");
	FRollbackTransaction Statement_RollbackTransaction;
	bool RollbackTransaction()
	{
		return Statement_RollbackTransaction.Execute();
	}

#Loc: <Workspace>/Engine/Plugins/Editor/AssetSearch/Source/Private/AssetSearchDatabase.cpp:75

Scope: file

Source code excerpt:


	 /** Begin a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FBeginTransaction, "BEGIN TRANSACTION;");
	FBeginTransaction Statement_BeginTransaction;
	bool BeginTransaction()
	{
		return Statement_BeginTransaction.Execute();
	}

	/** Commit a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FCommitTransaction, "COMMIT TRANSACTION;");
	FCommitTransaction Statement_CommitTransaction;
	bool CommitTransaction()
	{
		return Statement_CommitTransaction.Execute();
	}

	/** Rollback a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FRollbackTransaction, "ROLLBACK TRANSACTION;");
	FRollbackTransaction Statement_RollbackTransaction;
	bool RollbackTransaction()
	{
		return Statement_RollbackTransaction.Execute();
	}

#Loc: <Workspace>/Engine/Plugins/Editor/AssetSearch/Source/Private/FileInfoDatabase.cpp:63

Scope: file

Source code excerpt:


	 /** Begin a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FBeginTransaction, "BEGIN TRANSACTION;");
	FBeginTransaction Statement_BeginTransaction;
	bool BeginTransaction()
	{
		return Statement_BeginTransaction.Execute();
	}

	/** Commit a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FCommitTransaction, "COMMIT TRANSACTION;");
	FCommitTransaction Statement_CommitTransaction;
	bool CommitTransaction()
	{
		return Statement_CommitTransaction.Execute();
	}

	/** Rollback a database transaction */
	SQLITE_PREPARED_STATEMENT_SIMPLE(FRollbackTransaction, "ROLLBACK TRANSACTION;");
	FRollbackTransaction Statement_RollbackTransaction;
	bool RollbackTransaction()
	{
		return Statement_RollbackTransaction.Execute();
	}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorServer.cpp:5666

Scope: file

Source code excerpt:

	// Transaction tracking and control
	//
	else if( FParse::Command(&Str,TEXT("TRANSACTION")) )
	{
		if( Exec_Transaction( Str, Ar ) )
		{
			return true;
		}
	}