Lightweight 0.20261105.1
Loading...
Searching...
No Matches
Lightweight::Driver::SqlDriverStatementOperations Concept Reference

The statement operations a driver provides, as free functions found by argument-dependent lookup on its statement handle struct. More...

#include <Concept.hpp>

Concept definition

template<typename D>
concept Lightweight::Driver::SqlDriverStatementOperations = requires(D::Statement& stmt,
D::Statement const& constStmt,
D::Connection const& connection,
std::string_view query,
bool wideQueryText,
SqlColumnIndex column,
std::int16_t& count,
std::ptrdiff_t& rowCount,
std::chrono::seconds timeout,
std::chrono::seconds& timeoutOut,
SqlResult result,
std::source_location location,
SqlCatalogRequest const& catalogRequest,
int catalogDataType,
SqlColumnDescription& description,
SqlOutputColumnLength length,
std::uint16_t parameter,
char16_t* utf16Text,
std::size_t columnSize,
SqlIndicator& lengthIndicator) {
{ Allocate(connection, stmt) } -> std::same_as<SqlResult>;
{ Free(stmt) } -> std::same_as<void>;
{ Abandon(stmt) } -> std::same_as<void>;
{ Prepare(stmt, query, wideQueryText) } -> std::same_as<SqlResult>;
{ Execute(stmt) } -> std::same_as<SqlResult>;
{ ExecuteDirect(stmt, query, wideQueryText) } -> std::same_as<SqlResult>;
{ Fetch(stmt) } -> std::same_as<SqlResult>;
{ MoreResults(stmt) } -> std::same_as<SqlResult>;
{ CloseCursor(stmt) } -> std::same_as<void>;
{ DiscardResults(stmt) } -> std::same_as<void>;
{ UnbindColumns(stmt) } -> std::same_as<SqlResult>;
{ ResetParameters(stmt) } -> std::same_as<SqlResult>;
{ ResetParameterArrays(stmt) } -> std::same_as<void>;
{ NumResultColumns(constStmt, count) } -> std::same_as<SqlResult>;
{ NumParameters(constStmt, count) } -> std::same_as<SqlResult>;
{ NumRowsAffected(constStmt, rowCount) } -> std::same_as<SqlResult>;
{ ColumnType(constStmt, column) } -> std::same_as<std::expected<SqlResultColumnType, SqlErrorInfo>>;
{ SetQueryTimeout(stmt, timeout) } -> std::same_as<SqlResult>;
{ QueryTimeout(constStmt, timeoutOut) } -> std::same_as<SqlResult>;
{ Diagnose(constStmt) } -> std::same_as<SqlErrorInfo>;
{ RequireSuccess(constStmt, result, location) } -> std::same_as<void>;
{ CheckResult(constStmt, result, location) } -> std::same_as<CallOutcome>;
{ OpenCatalog(constStmt, catalogRequest) } -> std::same_as<SqlResult>;
{ CatalogColumnType(constStmt, catalogDataType) } -> std::same_as<SqlResultColumnType>;
{ DescribeColumn(constStmt, column, description) } -> std::same_as<SqlResult>;
{ DescribeResultColumnSqlType(constStmt, column) } -> std::same_as<std::optional<std::int16_t>>;
{ DeclaredBoundColumnSize(constStmt, column, length) } -> std::same_as<std::size_t>;
{ ResetRowArrayAttributes(stmt) } -> std::same_as<void>;
{ BindUtf16TextParameter(stmt, parameter, utf16Text, columnSize, lengthIndicator) } -> std::same_as<SqlResult>;
}
void ResetParameterArrays(StatementHandle &statement) noexcept
Restores single-row parameter binding after a parameter-array execution. Not reported.
Definition Dispatch.hpp:402
void CloseCursor(StatementHandle &statement) noexcept
Closes the cursor of a result set that was read to its end. Pending result sets are left alone.
Definition Dispatch.hpp:371
SqlResult UnbindColumns(StatementHandle &statement) noexcept
Unbinds every bound result column.
Definition Dispatch.hpp:387
std::optional< std::int16_t > DescribeResultColumnSqlType(StatementHandle const &statement, SqlColumnIndex column) noexcept
The driver's own SQL type code of a result column, as the driver's leaf binders read it (see SqlDataB...
Definition Dispatch.hpp:535
void Allocate(ConnectionHandle &connection) noexcept
Allocates the driver's connection resources, unless the connection already holds them.
Definition Dispatch.hpp:569
void RequireSuccess(StatementHandle const &statement, SqlResult result, std::source_location location=std::source_location::current())
Throws unless result indicates success: std::invalid_argument for a soft failure the caller is expect...
Definition Dispatch.hpp:477
SqlResult NumResultColumns(StatementHandle const &statement, std::int16_t &count) noexcept
Reports the number of columns of the current result set.
Definition Dispatch.hpp:411
SqlResult SetQueryTimeout(StatementHandle &statement, std::chrono::seconds timeout) noexcept
Sets the query timeout of the statement.
Definition Dispatch.hpp:449
void DiscardResults(StatementHandle &statement) noexcept
Drains every pending result set and closes the cursor, so the handle can run another query....
Definition Dispatch.hpp:379
void Free(StatementHandle &statement) noexcept
Frees the statement's driver handle and leaves statement empty, bound to the same driver.
Definition Dispatch.hpp:285
SqlResult OpenCatalog(StatementHandle const &statement, SqlCatalogRequest const &request)
Opens the catalog result set request names on statement, in the layout the ODBC specification gives t...
Definition Dispatch.hpp:502
SqlResult NumParameters(StatementHandle const &statement, std::int16_t &count) noexcept
Reports the number of parameters of the prepared statement.
Definition Dispatch.hpp:420
SqlResultColumnType CatalogColumnType(StatementHandle const &statement, int dataType) noexcept
The type a DATA_TYPE code of the driver's catalog result sets (see OpenCatalog) stands for.
Definition Dispatch.hpp:512
SqlResult QueryTimeout(StatementHandle const &statement, std::chrono::seconds &timeout) noexcept
Reports the query timeout of the statement.
Definition Dispatch.hpp:458
void ResetRowArrayAttributes(StatementHandle &statement) noexcept
Restores single-row fetching after a row-array fetch. Not reported; nothing for a driver without row ...
Definition Dispatch.hpp:558
SqlResult NumRowsAffected(StatementHandle const &statement, std::ptrdiff_t &count) noexcept
Reports the number of rows the last executed statement affected.
Definition Dispatch.hpp:429
std::size_t DeclaredBoundColumnSize(StatementHandle const &statement, SqlColumnIndex column, SqlOutputColumnLength length) noexcept
The declared length of a result column as a bound buffer size (see SqlDataBinderCallback::MinimumOutp...
Definition Dispatch.hpp:548
SqlErrorInfo Diagnose(StatementHandle const &statement)
Reads the statement's diagnostics: the first record its last failed call left.
Definition Dispatch.hpp:466
SqlResult DescribeColumn(StatementHandle const &statement, SqlColumnIndex column, SqlColumnDescription &description)
Describes a result column: its type and its size.
Definition Dispatch.hpp:522
SqlResult ResetParameters(StatementHandle &statement) noexcept
Drops every parameter binding.
Definition Dispatch.hpp:395
std::expected< SqlResultColumnType, SqlErrorInfo > ColumnType(StatementHandle const &statement, SqlColumnIndex column)
The SQL data type of a result column, as the driver describes it.
Definition Dispatch.hpp:439
SqlResult MoreResults(StatementHandle &statement) noexcept
Advances to the next pending result set.
Definition Dispatch.hpp:364
CallOutcome CheckResult(StatementHandle const &statement, SqlResult result, std::source_location location)
The non-throwing, fault-seam-aware verdict on result.
Definition Dispatch.hpp:489
LIGHTWEIGHT_FORCE_INLINE SqlResult BindUtf16TextParameter(Statement &stmt, std::uint16_t parameter, char16_t *text, std::size_t columnSize, SqlIndicator &lengthIndicator) noexcept
Binds UTF-16 text as an input parameter of SQL type SQL_WVARCHAR (SQLBindParameter with SQL_C_WCHAR)....
The statement operations a driver provides, as free functions found by argument-dependent lookup on i...
Definition Concept.hpp:210
@ Execute
The execution of a prepared statement (SqlStatement::Execute).
@ ExecuteDirect
The execution of a one-shot statement (SqlStatement::ExecuteDirect).
@ Prepare
The preparation of a statement (SqlStatement::Prepare).

Detailed Description

The statement operations a driver provides, as free functions found by argument-dependent lookup on its statement handle struct.

Each returns the driver's result code rather than throwing, so the caller decides how to check it; Diagnose, RequireSuccess and CheckResult are the driver's ways of checking one.

Catalog access is part of it, so that the schema reader compiles against every driver without naming one: OpenCatalog opens the result set of a Lightweight::Driver::SqlCatalogRequest in ODBC's catalog layout, and CatalogColumnType reads that layout's type codes. A driver without catalog functions (HasCatalogFunctions is false) implements both with the one "not supported by this driver" error (SQLSTATE IM001) and the type Unknown; SqlSchema never calls them on it, since it reads that driver's catalog with the SQL of SqlQueryFormatter::CatalogQueries(). Likewise each operation a driver has no data for answers with that error or the stated neutral value (no SQL type code, the default bound size, nothing to reset), never by being absent: shared code calls every operation unconditionally.

Definition at line 210 of file Concept.hpp.