userver: storages::postgres::TransactionOptions Struct Reference
Loading...
Searching...
No Matches
storages::postgres::TransactionOptions Struct Reference

#include <userver/storages/postgres/options.hpp>

Detailed Description

PostgreSQL transaction options.

A transaction can be started using all isolation levels and modes supported by PostgreSQL server as specified in it's documentation.

Default isolation level is READ COMMITTED, default mode is READ WRITE.

// Read-write read committed transaction.

Transaction class provides constants Transaction::RW, Transaction::RO and Transaction::Deferrable for convenience.

Other variants can be created with TransactionOptions constructors that are constexpr.

See also
https://www.postgresql.org/docs/current/static/sql-set-transaction.html
Examples
postgresql/functional_tests/basic_chaos/postgres_service.cpp.

Definition at line 52 of file options.hpp.

Public Types

enum  Mode {
  kReadWrite = 0 ,
  kReadOnly = 1 ,
  kDeferrable = 3
}
 

Public Member Functions

constexpr TransactionOptions (IsolationLevel lvl)
 
constexpr TransactionOptions (IsolationLevel lvl, Mode m)
 
constexpr TransactionOptions (Mode m)
 
bool IsReadOnly () const
 

Static Public Member Functions

static constexpr TransactionOptions Deferrable ()
 

Public Attributes

IsolationLevel isolation_level = IsolationLevel::kReadCommitted
 
Mode mode = kReadWrite
 

Member Enumeration Documentation

◆ Mode

[Transaction modes]

Enumerator
kDeferrable 

Deferrable transaction is read only.

Definition at line 54 of file options.hpp.

Constructor & Destructor Documentation

◆ TransactionOptions() [1/3]

constexpr storages::postgres::TransactionOptions::TransactionOptions ( IsolationLevel lvl)
inlineexplicitconstexpr

Definition at line 64 of file options.hpp.

◆ TransactionOptions() [2/3]

constexpr storages::postgres::TransactionOptions::TransactionOptions ( IsolationLevel lvl,
Mode m )
inlineconstexpr

Definition at line 65 of file options.hpp.

◆ TransactionOptions() [3/3]

constexpr storages::postgres::TransactionOptions::TransactionOptions ( Mode m)
inlineexplicitconstexpr

Definition at line 66 of file options.hpp.

Member Function Documentation

◆ Deferrable()

static constexpr TransactionOptions storages::postgres::TransactionOptions::Deferrable ( )
inlinestaticconstexpr

The deferrable property has effect only if the transaction is also serializable and read only

Definition at line 72 of file options.hpp.

◆ IsReadOnly()

bool storages::postgres::TransactionOptions::IsReadOnly ( ) const
inline

Definition at line 68 of file options.hpp.

Member Data Documentation

◆ isolation_level

IsolationLevel storages::postgres::TransactionOptions::isolation_level = IsolationLevel::kReadCommitted

[Transaction modes]

Definition at line 60 of file options.hpp.

◆ mode

Mode storages::postgres::TransactionOptions::mode = kReadWrite

Definition at line 61 of file options.hpp.


The documentation for this struct was generated from the following file: