Cppgres
Build Postgres extensions in C++
Loading...
Searching...
No Matches
cppgres::spi_executor Struct Reference

SPI executor API More...

#include <executor.hpp>

Inheritance diagram for cppgres::spi_executor:
cppgres::executor cppgres::spi_nonatomic_executor

Classes

struct  options
 
struct  result_iterator
 
struct  results
 

Public Member Functions

 spi_executor ()
 Creates an SPI executor.
 
 spi_executor (spi_opt opts)
 Creates an SPI executor with explicitly chosen options.
 
template<typename Ret , convertible_into_nullable_datum_and_has_a_type... Args>
results< Ret > query (utils::convertible_to_cstring auto query, Args &&...args)
 Queries using a string view.
 
template<typename Ret , convertible_into_nullable_datum_and_has_a_type... Args>
results< Ret > query (utils::convertible_to_cstring auto query, options &&opts, Args &&...args)
 Queries using a string view.
 
template<convertible_into_nullable_datum_and_has_a_type... Args>
spi_plan< Args... > plan (utils::convertible_to_cstring auto query)
 
template<typename Ret , convertible_into_nullable_datum... Args>
results< Ret > query (spi_plan< Args... > &query, Args &&...args)
 
template<typename Ret , convertible_into_nullable_datum... Args>
results< Ret > query (spi_plan< Args... > &query, options &&opts, Args &&...args)
 
template<convertible_into_nullable_datum_and_has_a_type... Args>
uint64_t execute (std::string_view query, Args &&...args)
 
template<convertible_into_nullable_datum_and_has_a_type... Args>
uint64_t execute (std::string_view query, options &&opts, Args &&...args)
 

Static Public Member Functions

static spi_executorcurrent ()
 The innermost live SPI executor.
 

Protected Member Functions

 spi_executor (int flags)
 

Static Protected Attributes

static std::stack< spi_executor * > executors
 

Detailed Description

SPI executor API

Constructor & Destructor Documentation

◆ spi_executor()

cppgres::spi_executor::spi_executor ( spi_opt  opts)
inlineexplicit

Creates an SPI executor with explicitly chosen options.

This is meant for code running outside of the cppgres function-call context (such as raw language handlers) that determines atomicity by itself and therefore can't rely on cppgres::spi_nonatomic_executor's context inference.

Member Function Documentation

◆ current()

static spi_executor & cppgres::spi_executor::current ( )
inlinestatic

The innermost live SPI executor.

Exceptions
std::runtime_errorif no SPI executor is in scope

◆ query() [1/2]

template<typename Ret , convertible_into_nullable_datum_and_has_a_type... Args>
results< Ret > cppgres::spi_executor::query ( utils::convertible_to_cstring auto  query,
Args &&...  args 
)
inline

Queries using a string view.

Parameters
queryQuery string
argsQuery arguments
Note
if you need to be able to configure the execution, use another version of the function with cppgres::spi_executor::options argument
Returns
Iterable cppgres::spi_executor::results, can be a single value
Exceptions
std::runtime_errorif there's another SPI executor in scope
std::runtime_errorif there's an SPI error

◆ query() [2/2]

template<typename Ret , convertible_into_nullable_datum_and_has_a_type... Args>
results< Ret > cppgres::spi_executor::query ( utils::convertible_to_cstring auto  query,
options &&  opts,
Args &&...  args 
)
inline

Queries using a string view.

Parameters
queryQuery string
optsExecution options
argsQuery arguments
Returns
Iterable cppgres::spi_executor::results, can be a single value
Exceptions
std::runtime_errorif there's another SPI executor in scope
std::runtime_errorif there's an SPI error

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