userver: storages::sqlite::Savepoint Class Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
storages::sqlite::Savepoint Class Referencefinal

#include <userver/storages/sqlite/savepoint.hpp>

Detailed Description

RAII savepoint wrapper, auto-ROLLBACKs on destruction if no prior Release/Rollback call was made.

This type can't be constructed in user code and is always retrieved from storages::sqlite::Client

Definition at line 23 of file savepoint.hpp.

Public Member Functions

 Savepoint (std::shared_ptr< infra::ConnectionPtr > connection, std::string name)
 
 Savepoint (const Savepoint &other)=delete
 
 Savepoint (Savepoint &&other) noexcept
 
Savepointoperator= (Savepoint &&) noexcept
 
template<typename... Args>
ResultSet Execute (const Query &query, const Args &... args) const
 Executes a statement.
 
template<typename T>
ResultSet ExecuteDecompose (const Query &query, const T &row) const
 Executes a statement, decomposing the row.
 
template<typename Container>
void ExecuteMany (const Query &query, const Container &params) const
 Executes a statement multiple times.
 
template<typename T, typename... Args>
CursorResultSet< T > GetCursor (std::size_t batch_size, const Query &query, const Args &... args) const
 Executes a statement and returns a cursor for iterating over results.
 
Savepoint Save (std::string name) const
 Creates a wrapped savepoint with specified name.
 
void Release ()
 Release the savepint.
 
void RollbackTo ()
 Rollback the savepint.
 

Member Function Documentation

◆ Execute()

template<typename... Args>
ResultSet storages::sqlite::Savepoint::Execute ( const Query & query,
const Args &... args ) const

Executes a statement.

Fills placeholders of the statement with args..., Args are expected to be of supported types. See SQLite supported types for better understanding of Args requirements.

Template Parameters
ArgsTypes of parameters to bind
Parameters
querySQL query to execute
argsParameters to bind to the query
Returns
ResultSet containing the results of the query

Definition at line 112 of file savepoint.hpp.

◆ ExecuteDecompose()

template<typename T>
ResultSet storages::sqlite::Savepoint::ExecuteDecompose ( const Query & query,
const T & row ) const

Executes a statement, decomposing the row.

Decomposes the fields of the row and binds them as parameters to the query. See SQLite supported types for better understanding of T requirements.

Template Parameters
TType of the row to decompose
Parameters
querySQL query to execute
rowRow object to decompose and bind
Returns
ResultSet containing the results of the query

Definition at line 125 of file savepoint.hpp.

◆ ExecuteMany()

template<typename Container>
void storages::sqlite::Savepoint::ExecuteMany ( const Query & query,
const Container & params ) const

Executes a statement multiple times.

Iterates over the container and executes the query for each element. Container is expected to be a std::Container, Container::value_type is expected to be an aggregate of supported types. See MySQL supported types for better understanding of Container::value_type requirements.

Template Parameters
ContainerType of the container holding rows
Parameters
querySQL query to execute
paramsContainer of rows to bind and execute

Definition at line 138 of file savepoint.hpp.

◆ GetCursor()

template<typename T, typename... Args>
CursorResultSet< T > storages::sqlite::Savepoint::GetCursor ( std::size_t batch_size,
const Query & query,
const Args &... args ) const

Executes a statement and returns a cursor for iterating over results.

Fills placeholders of the statement with args..., Args are expected to be of supported types. See SQLite supported types for better understanding of Args requirements.

Template Parameters
TType of the result rows
ArgsTypes of parameters to bind
Parameters
batch_sizeNumber of rows to fetch per batch
querySQL query to execute
argsParameters to bind to the query
Returns
CursorResultSet for iterating over the results

Definition at line 153 of file savepoint.hpp.

◆ Save()

Savepoint storages::sqlite::Savepoint::Save ( std::string name) const

Creates a wrapped savepoint with specified name.

Parameters
nameName of the savepoint
Returns
Savepoint object representing the created savepoint

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