Lightweight 0.20261105.1
Loading...
Searching...
No Matches
Dispatch.hpp File Reference
#include "../Api.hpp"
#include "../SqlBindingTypes.hpp"
#include "../SqlConnectInfo.hpp"
#include "../SqlError.hpp"
#include "../SqlServerType.hpp"
#include "Concept.hpp"
#include "DriverSet.hpp"
#include <chrono>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <format>
#include <functional>
#include <optional>
#include <source_location>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

Go to the source code of this file.

Functions

constexpr bool Lightweight::Driver::IsEnabled (SqlDriverId id) noexcept
 Whether the library was built with driver id (a fold over the enabled drivers).
 
constexpr std::string_view Lightweight::Driver::NameOf (SqlDriverId id) noexcept
 The display name of an enabled driver, as error messages show it.
 
constexpr bool Lightweight::Driver::SupportsParameterArrays (SqlDriverId id) noexcept
 Whether an enabled driver executes parameter arrays natively (one call per batch).
 
constexpr bool Lightweight::Driver::SupportsRowArrayFetch (SqlDriverId id) noexcept
 Whether an enabled driver fetches blocks of rows into array-bound columns natively.
 
constexpr bool Lightweight::Driver::StatementsDieWithConnection (SqlDriverId id) noexcept
 Whether closing a connection of an enabled driver destroys its statement handles, so that they must not be freed afterwards.
 
constexpr bool Lightweight::Driver::TranscodesNarrowText (SqlDriverId id) noexcept
 Whether an enabled driver may pass narrow text through a client codepage, so that whether narrow text round-trips byte-exact depends on the backend.
 
constexpr bool Lightweight::Driver::HasCatalogFunctions (SqlDriverId id) noexcept
 Whether an enabled driver reads a database's catalog with catalog functions of its own (ODBC's SQLTables, SQLColumns, ...); false when SqlSchema reads it with the SQL of SqlQueryFormatter::CatalogQueries().
 
SqlResult Lightweight::Driver::AllocateStatement (ConnectionHandle const &connection, StatementHandle &statement) noexcept
 Allocates a statement of the connection's driver and binds statement to that driver.
 
void Lightweight::Driver::Free (StatementHandle &statement) noexcept
 Frees the statement's driver handle and leaves statement empty, bound to the same driver.
 
void Lightweight::Driver::Abandon (StatementHandle &statement) noexcept
 Gives up the statement's driver handle after its connection session ended, and leaves statement empty, bound to the same driver: what died with the session is not touched again, what the driver still holds for the statement is released (see each driver's Abandon).
 
StatementHandle Lightweight::Driver::Alias (StatementHandle const &statement) noexcept
 A second handle naming the same driver statement as statement (its driver struct copied, see SqlDriverHandleStruct): it owns nothing more, so only one of the two may free it.
 
bool Lightweight::Driver::SameStatement (StatementHandle const &first, StatementHandle const &second) noexcept
 Tells whether two handles name the same driver statement.
 
SqlResult Lightweight::Driver::Prepare (StatementHandle &statement, std::string_view query, bool wideQueryText)
 Prepares query on the statement.
 
LIGHTWEIGHT_FORCE_INLINE SqlResult Lightweight::Driver::Execute (StatementHandle &statement) noexcept
 Executes the prepared statement with the currently bound parameters.
 
SqlResult Lightweight::Driver::ExecuteDirect (StatementHandle &statement, std::string_view query, bool wideQueryText)
 Executes query directly, without preparing it.
 
LIGHTWEIGHT_FORCE_INLINE SqlResult Lightweight::Driver::Fetch (StatementHandle &statement) noexcept
 Fetches the next row of the result set into the bound columns.
 
SqlResult Lightweight::Driver::MoreResults (StatementHandle &statement) noexcept
 Advances to the next pending result set.
 
void Lightweight::Driver::CloseCursor (StatementHandle &statement) noexcept
 Closes the cursor of a result set that was read to its end. Pending result sets are left alone.
 
void Lightweight::Driver::DiscardResults (StatementHandle &statement) noexcept
 Drains every pending result set and closes the cursor, so the handle can run another query. An error met while draining is not reported.
 
SqlResult Lightweight::Driver::UnbindColumns (StatementHandle &statement) noexcept
 Unbinds every bound result column.
 
SqlResult Lightweight::Driver::ResetParameters (StatementHandle &statement) noexcept
 Drops every parameter binding.
 
void Lightweight::Driver::ResetParameterArrays (StatementHandle &statement) noexcept
 Restores single-row parameter binding after a parameter-array execution. Not reported.
 
SqlResult Lightweight::Driver::NumResultColumns (StatementHandle const &statement, std::int16_t &count) noexcept
 Reports the number of columns of the current result set.
 
SqlResult Lightweight::Driver::NumParameters (StatementHandle const &statement, std::int16_t &count) noexcept
 Reports the number of parameters of the prepared statement.
 
SqlResult Lightweight::Driver::NumRowsAffected (StatementHandle const &statement, std::ptrdiff_t &count) noexcept
 Reports the number of rows the last executed statement affected.
 
std::expected< SqlResultColumnType, SqlErrorInfo > Lightweight::Driver::ColumnType (StatementHandle const &statement, SqlColumnIndex column)
 The SQL data type of a result column, as the driver describes it.
 
SqlResult Lightweight::Driver::SetQueryTimeout (StatementHandle &statement, std::chrono::seconds timeout) noexcept
 Sets the query timeout of the statement.
 
SqlResult Lightweight::Driver::QueryTimeout (StatementHandle const &statement, std::chrono::seconds &timeout) noexcept
 Reports the query timeout of the statement.
 
SqlErrorInfo Lightweight::Driver::Diagnose (StatementHandle const &statement)
 Reads the statement's diagnostics: the first record its last failed call left.
 
void Lightweight::Driver::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 expected to recover from, SqlException otherwise (see ClassifyResult).
 
CallOutcome Lightweight::Driver::CheckResult (StatementHandle const &statement, SqlResult result, std::source_location location)
 The non-throwing, fault-seam-aware verdict on result.
 
SqlResult Lightweight::Driver::OpenCatalog (StatementHandle const &statement, SqlCatalogRequest const &request)
 Opens the catalog result set request names on statement, in the layout the ODBC specification gives that catalog function.
 
SqlResultColumnType Lightweight::Driver::CatalogColumnType (StatementHandle const &statement, int dataType) noexcept
 The type a DATA_TYPE code of the driver's catalog result sets (see OpenCatalog) stands for.
 
SqlResult Lightweight::Driver::DescribeColumn (StatementHandle const &statement, SqlColumnIndex column, SqlColumnDescription &description)
 Describes a result column: its type and its size.
 
std::optional< std::int16_t > Lightweight::Driver::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 SqlDataBinderCallback::DescribeResultColumnType).
 
std::size_t Lightweight::Driver::DeclaredBoundColumnSize (StatementHandle const &statement, SqlColumnIndex column, SqlOutputColumnLength length) noexcept
 The declared length of a result column as a bound buffer size (see SqlDataBinderCallback::MinimumOutputColumnSize).
 
void Lightweight::Driver::ResetRowArrayAttributes (StatementHandle &statement) noexcept
 Restores single-row fetching after a row-array fetch. Not reported; nothing for a driver without row arrays.
 
void Lightweight::Driver::Allocate (ConnectionHandle &connection) noexcept
 Allocates the driver's connection resources, unless the connection already holds them.
 
std::expected< void, SqlErrorInfo > Lightweight::Driver::Close (ConnectionHandle &connection, CloseDiagnostic diagnostic) noexcept
 Closes the connection: disconnects it, frees its driver resources and leaves connection empty, bound to the same driver. Not reported.
 
SqlResult Lightweight::Driver::Disconnect (ConnectionHandle &connection) noexcept
 Ends the connection's session, keeping its driver resources for the next connect.
 
bool Lightweight::Driver::IsAllocated (ConnectionHandle const &connection) noexcept
 Tells whether connection holds a driver connection (connected or not).
 
bool Lightweight::Driver::IsAlive (ConnectionHandle const &connection) noexcept
 Tells whether the driver still considers the connection alive.
 
SqlErrorInfo Lightweight::Driver::LastError (ConnectionHandle const &connection)
 Reads the connection's diagnostics: the first record its last failed call left.
 
CallOutcome Lightweight::Driver::CheckResult (ConnectionHandle const &connection, SqlResult result, std::source_location location)
 The non-throwing, fault-seam-aware verdict on result of a call on connection.
 
std::string Lightweight::Driver::ServerName (ConnectionHandle const &connection)
 The name of the DBMS the connection is connected to.
 
std::string Lightweight::Driver::ServerVersion (ConnectionHandle const &connection)
 The version of the DBMS the connection is connected to.
 
std::string Lightweight::Driver::DriverName (ConnectionHandle const &connection)
 The name of the driver (library) the connection runs on.
 
std::string Lightweight::Driver::DatabaseName (ConnectionHandle const &connection)
 The name of the database in use.
 
std::string Lightweight::Driver::UserName (ConnectionHandle const &connection)
 The name of the user the connection is logged in as.
 
bool Lightweight::Driver::TransactionActive (ConnectionHandle const &connection) noexcept
 Tells whether a transaction is open, i.e. autocommit is off.
 
bool Lightweight::Driver::TransactionsAllowed (ConnectionHandle const &connection) noexcept
 Tells whether the data source supports transactions.
 
SqlResult Lightweight::Driver::SetAutoCommit (ConnectionHandle &connection, bool enabled) noexcept
 Switches autocommit mode on or off.
 
SqlResult Lightweight::Driver::Commit (ConnectionHandle &connection) noexcept
 Commits the open transaction.
 
SqlResult Lightweight::Driver::Rollback (ConnectionHandle &connection) noexcept
 Rolls back the open transaction.
 
SqlResult Lightweight::Driver::SetIsolation (ConnectionHandle &connection, SqlIsolationMode mode) noexcept
 Sets the transaction isolation level of the connection.
 
bool Lightweight::Driver::RollbackOpenTransaction (ConnectionHandle &connection) noexcept
 Rolls back the open transaction and switches autocommit back on.
 
std::expected< std::string, SqlErrorInfo > Lightweight::Driver::SearchPatternEscape (ConnectionHandle const &connection)
 The string the driver escapes the wildcards of a catalog search pattern with (see OpenCatalog).
 
template<typename Info >
bool Lightweight::Driver::RebindsDriverFor (ConnectionHandle const &handle) noexcept
 Tells whether connecting from Info binds handle to another driver than the one it is bound to.
 
template<typename Info >
void Lightweight::Driver::BindDriverFor (ConnectionHandle &handle) noexcept
 Binds handle to the enabled driver D for which Connect(D::Connection&, Info const&, std::source_location) is well-formed (found by argument-dependent lookup), closing what the handle held if that was another driver's. No such driver: no change.
 
template<typename Info >
std::expected< void, SqlErrorInfo > Lightweight::Driver::Connect (ConnectionHandle &handle, Info const &info, std::source_location location)
 Connects handle from info through the enabled driver that connects from it.
 
bool Lightweight::Driver::AcceptsWideQueryText (ConnectionHandle const &connection) noexcept
 Tells whether the connection's driver receives wide (UTF-16) query text unchanged.
 
bool Lightweight::Driver::ReadsBoundColumnsAgain (ConnectionHandle const &connection) noexcept
 Tells whether the connection's driver can read a bound output column again, so that a bound value longer than its buffer is read in full (see SqlConnection::ReadsBoundColumnsAgain).
 
::Lightweight::detail::NarrowTextBinding Lightweight::Driver::NarrowTextBinding (ConnectionHandle const &connection, SqlServerType serverType, SqlConnectInfo const &connectInfo)
 Tells how the narrow string binders exchange text with the connection's driver (see SqlConnection::NarrowTextBindingMode).
 
std::string Lightweight::Driver::DriverNameOf (ConnectionHandle const &connection, SqlConnectionString const &connectionString)
 Names the driver a connect from connectionString reaches, without connecting (see ServerTypeFromDriverName): the connection string's own DRIVER, else what the driver manager lists for its DSN.
 
void Lightweight::Driver::RegisterTextEntry (ConnectionHandle const &connection, bool acceptsWideQueryText) noexcept
 Records whether the connection's driver takes text through its wide entry points, where the driver has such a choice; does nothing otherwise.
 
void Lightweight::Driver::RegisterAnsiOnly (StatementHandle const &statement, ConnectionHandle const &connection) noexcept
 Records statement as belonging to a connection whose driver takes text only through its ANSI entry points, where the driver has such a choice; does nothing otherwise.
 
std::vector< std::int16_t > Lightweight::Driver::DescribeParameterTypes (StatementHandle const &statement, std::size_t count)
 Describes the declared SQL type of each of the first count parameters.
 
std::int16_t Lightweight::Driver::BoundParameterCount (StatementHandle const &statement) noexcept
 The number of parameters currently bound on the statement.
 
template<typename Handle , typename F >
requires detail::TaggedHandle<std::remove_cvref_t<Handle>>
void Lightweight::Driver::VisitIfSupported (Handle &&handle, F &&f)
 Calls f with the held struct when f is invocable with it; otherwise does nothing.
 
template<typename Handle , typename F >
requires detail::TaggedHandle<std::remove_cvref_t<Handle>>
decltype(auto) Lightweight::Driver::VisitRequired (Handle &&handle, std::string_view operation, F &&f)
 Calls f with the held struct when invocable; otherwise throws SqlException(NotSupportedByDriver(id, operation)).
 

Variables

constexpr bool Lightweight::Driver::RefusesUnsetDefaultConnectInfo = !IsEnabled(SqlDriverId::Odbc)
 Whether a connection opened from the default connect info refuses to connect while no default was set (see SqlConnection::SetDefaultConnectInfo): with SQLSTATE 08001 instead of opening what the unset default names. Holds in a build without the ODBC driver, whose unset default would be a SqliteConnectInfo naming a private temporary database. With ODBC the unset default is an empty connection string, which the driver manager refuses itself.
 

Detailed Description

The driver-neutral face of the Lightweight::Driver::SqlDriver concept: one function per concept operation, taking the tagged Lightweight::Driver::StatementHandle / Lightweight::Driver::ConnectionHandle instead of a driver's handle struct, plus the optional operations only some drivers provide and the typed visits for code that exists for one driver only.

Each function visits the handle and calls the driver's function unqualified inside the visit, so that it is found by argument-dependent lookup on the driver's handle struct. A dispatch function itself never matches a driver struct (the handles' constructors are explicit), so a driver lacking a required operation is a compile error rather than a recursion into the dispatch function. The layer exists because inside SqlStatement / SqlConnection members argument-dependent lookup is suppressed by the same-named members.

Definition in file Dispatch.hpp.

Function Documentation

◆ IsEnabled()

constexpr bool Lightweight::Driver::IsEnabled ( SqlDriverId  id)
constexprnoexcept

Whether the library was built with driver id (a fold over the enabled drivers).

Parameters
idThe driver's id; every known driver has one, whether or not the build contains it.
Returns
true when the driver is one of the enabled drivers.

Definition at line 197 of file Dispatch.hpp.

◆ NameOf()

constexpr std::string_view Lightweight::Driver::NameOf ( SqlDriverId  id)
constexprnoexcept

The display name of an enabled driver, as error messages show it.

Parameters
idThe driver's id.
Returns
The driver's Name (e.g. "ODBC"); "unknown" for an id no enabled driver has.

Definition at line 212 of file Dispatch.hpp.

◆ SupportsParameterArrays()

constexpr bool Lightweight::Driver::SupportsParameterArrays ( SqlDriverId  id)
constexprnoexcept

Whether an enabled driver executes parameter arrays natively (one call per batch).

Parameters
idThe driver's id.
Returns
The driver's SupportsParameterArrays; false for an id no enabled driver has.

Definition at line 220 of file Dispatch.hpp.

References Lightweight::Driver::SupportsParameterArrays().

Referenced by Lightweight::Driver::SupportsParameterArrays().

◆ SupportsRowArrayFetch()

constexpr bool Lightweight::Driver::SupportsRowArrayFetch ( SqlDriverId  id)
constexprnoexcept

Whether an enabled driver fetches blocks of rows into array-bound columns natively.

Parameters
idThe driver's id.
Returns
The driver's SupportsRowArrayFetch; false for an id no enabled driver has.

Definition at line 229 of file Dispatch.hpp.

References Lightweight::Driver::SupportsRowArrayFetch().

Referenced by Lightweight::Driver::SupportsRowArrayFetch().

◆ StatementsDieWithConnection()

constexpr bool Lightweight::Driver::StatementsDieWithConnection ( SqlDriverId  id)
constexprnoexcept

Whether closing a connection of an enabled driver destroys its statement handles, so that they must not be freed afterwards.

Parameters
idThe driver's id.
Returns
The driver's StatementsDieWithConnection; false for an id no enabled driver has.

Definition at line 239 of file Dispatch.hpp.

References Lightweight::Driver::StatementsDieWithConnection().

Referenced by Lightweight::Driver::StatementsDieWithConnection().

◆ TranscodesNarrowText()

constexpr bool Lightweight::Driver::TranscodesNarrowText ( SqlDriverId  id)
constexprnoexcept

Whether an enabled driver may pass narrow text through a client codepage, so that whether narrow text round-trips byte-exact depends on the backend.

Parameters
idThe driver's id.
Returns
The driver's TranscodesNarrowText; false for an id no enabled driver has.

Definition at line 249 of file Dispatch.hpp.

References Lightweight::Driver::TranscodesNarrowText().

Referenced by Lightweight::Driver::TranscodesNarrowText().

◆ HasCatalogFunctions()

constexpr bool Lightweight::Driver::HasCatalogFunctions ( SqlDriverId  id)
constexprnoexcept

Whether an enabled driver reads a database's catalog with catalog functions of its own (ODBC's SQLTables, SQLColumns, ...); false when SqlSchema reads it with the SQL of SqlQueryFormatter::CatalogQueries().

Parameters
idThe driver's id.
Returns
The driver's HasCatalogFunctions; false for an id no enabled driver has.

Definition at line 259 of file Dispatch.hpp.

References Lightweight::Driver::HasCatalogFunctions().

Referenced by Lightweight::Driver::HasCatalogFunctions().

◆ AllocateStatement()

SqlResult Lightweight::Driver::AllocateStatement ( ConnectionHandle const &  connection,
StatementHandle &  statement 
)
inlinenoexcept

Allocates a statement of the connection's driver and binds statement to that driver.

Parameters
connectionThe connection to allocate on.
statementReceives the statement; whatever it held before is forgotten, not freed. It is bound to the connection's driver whatever the result, and empty on failure.
Returns
The driver's result of allocating.

Definition at line 272 of file Dispatch.hpp.

References Lightweight::Driver::Allocate(), and Lightweight::Driver::AllocateStatement().

Referenced by Lightweight::Driver::AllocateStatement().

◆ Free()

void Lightweight::Driver::Free ( StatementHandle &  statement)
inlinenoexcept

Frees the statement's driver handle and leaves statement empty, bound to the same driver.

Parameters
statementThe statement; may be empty.

Definition at line 285 of file Dispatch.hpp.

References Lightweight::Driver::Free().

Referenced by Lightweight::Driver::Odbc::Free(), Lightweight::Driver::Sqlite3::Free(), and Lightweight::Driver::Free().

◆ Abandon()

void Lightweight::Driver::Abandon ( StatementHandle &  statement)
inlinenoexcept

Gives up the statement's driver handle after its connection session ended, and leaves statement empty, bound to the same driver: what died with the session is not touched again, what the driver still holds for the statement is released (see each driver's Abandon).

Parameters
statementThe statement; may be empty.

Definition at line 294 of file Dispatch.hpp.

References Lightweight::Driver::Abandon().

Referenced by Lightweight::Driver::Odbc::Abandon(), Lightweight::Driver::Sqlite3::Abandon(), and Lightweight::Driver::Abandon().

◆ Alias()

StatementHandle Lightweight::Driver::Alias ( StatementHandle const &  statement)
inlinenoexcept

A second handle naming the same driver statement as statement (its driver struct copied, see SqlDriverHandleStruct): it owns nothing more, so only one of the two may free it.

Parameters
statementThe statement.
Returns
The alias, bound to the same driver.

Definition at line 303 of file Dispatch.hpp.

References Lightweight::Driver::Alias().

Referenced by Lightweight::Driver::Alias().

◆ SameStatement()

bool Lightweight::Driver::SameStatement ( StatementHandle const &  first,
StatementHandle const &  second 
)
inlinenoexcept

Tells whether two handles name the same driver statement.

Parameters
firstOne handle.
secondThe other handle.
Returns
true when both are bound to the same driver and hold equal structs.

Definition at line 312 of file Dispatch.hpp.

References Lightweight::Driver::SameStatement().

Referenced by Lightweight::Driver::SameStatement().

◆ Prepare()

SqlResult Lightweight::Driver::Prepare ( StatementHandle &  statement,
std::string_view  query,
bool  wideQueryText 
)
inline

Prepares query on the statement.

Parameters
statementThe statement.
queryThe SQL text, UTF-8.
wideQueryTextWhether the driver is to receive the text as UTF-16 (see SqlConnection::AcceptsWideQueryText()); a driver taking UTF-8 only ignores it.
Returns
The driver's result.

Definition at line 330 of file Dispatch.hpp.

References Prepare.

◆ Execute()

LIGHTWEIGHT_FORCE_INLINE SqlResult Lightweight::Driver::Execute ( StatementHandle &  statement)
inlinenoexcept

Executes the prepared statement with the currently bound parameters.

Parameters
statementThe statement.
Returns
The driver's result; SqlResult::NoData for a searched UPDATE/DELETE that matched no rows.

Definition at line 338 of file Dispatch.hpp.

References Execute.

◆ ExecuteDirect()

SqlResult Lightweight::Driver::ExecuteDirect ( StatementHandle &  statement,
std::string_view  query,
bool  wideQueryText 
)
inline

Executes query directly, without preparing it.

Parameters
statementThe statement.
queryThe SQL text, UTF-8.
wideQueryTextAs for Prepare.
Returns
The driver's result.

Definition at line 348 of file Dispatch.hpp.

References ExecuteDirect.

◆ Fetch()

LIGHTWEIGHT_FORCE_INLINE SqlResult Lightweight::Driver::Fetch ( StatementHandle &  statement)
inlinenoexcept

Fetches the next row of the result set into the bound columns.

Parameters
statementThe statement.
Returns
The driver's result; SqlResult::NoData past the last row.

Definition at line 356 of file Dispatch.hpp.

References Fetch.

◆ MoreResults()

SqlResult Lightweight::Driver::MoreResults ( StatementHandle &  statement)
inlinenoexcept

Advances to the next pending result set.

Parameters
statementThe statement.
Returns
The driver's result; SqlResult::NoData when none is pending.

Definition at line 364 of file Dispatch.hpp.

References Lightweight::Driver::MoreResults().

Referenced by Lightweight::Driver::Odbc::DiscardResults(), Lightweight::Driver::Odbc::MoreResults(), Lightweight::Driver::Sqlite3::MoreResults(), and Lightweight::Driver::MoreResults().

◆ CloseCursor()

void Lightweight::Driver::CloseCursor ( StatementHandle &  statement)
inlinenoexcept

Closes the cursor of a result set that was read to its end. Pending result sets are left alone.

Parameters
statementThe statement.

Definition at line 371 of file Dispatch.hpp.

References Lightweight::Driver::CloseCursor().

Referenced by Lightweight::Driver::Odbc::CloseCursor(), Lightweight::Driver::Sqlite3::CloseCursor(), and Lightweight::Driver::CloseCursor().

◆ DiscardResults()

void Lightweight::Driver::DiscardResults ( StatementHandle &  statement)
inlinenoexcept

Drains every pending result set and closes the cursor, so the handle can run another query. An error met while draining is not reported.

Parameters
statementThe statement.

Definition at line 379 of file Dispatch.hpp.

References Lightweight::Driver::DiscardResults().

Referenced by Lightweight::Driver::Odbc::DiscardResults(), Lightweight::Driver::Sqlite3::DiscardResults(), and Lightweight::Driver::DiscardResults().

◆ UnbindColumns()

SqlResult Lightweight::Driver::UnbindColumns ( StatementHandle &  statement)
inlinenoexcept

Unbinds every bound result column.

Parameters
statementThe statement.
Returns
The driver's result.

Definition at line 387 of file Dispatch.hpp.

References Lightweight::Driver::UnbindColumns().

Referenced by Lightweight::Driver::Odbc::UnbindColumns(), Lightweight::Driver::Sqlite3::UnbindColumns(), and Lightweight::Driver::UnbindColumns().

◆ ResetParameters()

SqlResult Lightweight::Driver::ResetParameters ( StatementHandle &  statement)
inlinenoexcept

Drops every parameter binding.

Parameters
statementThe statement.
Returns
The driver's result.

Definition at line 395 of file Dispatch.hpp.

References Lightweight::Driver::ResetParameters().

Referenced by Lightweight::Driver::Odbc::ResetParameters(), Lightweight::Driver::Sqlite3::ResetParameters(), and Lightweight::Driver::ResetParameters().

◆ ResetParameterArrays()

void Lightweight::Driver::ResetParameterArrays ( StatementHandle &  statement)
inlinenoexcept

Restores single-row parameter binding after a parameter-array execution. Not reported.

Parameters
statementThe statement.

Definition at line 402 of file Dispatch.hpp.

References Lightweight::Driver::ResetParameterArrays().

Referenced by Lightweight::Driver::Odbc::ResetParameterArrays(), Lightweight::Driver::Sqlite3::ResetParameterArrays(), and Lightweight::Driver::ResetParameterArrays().

◆ NumResultColumns()

SqlResult Lightweight::Driver::NumResultColumns ( StatementHandle const &  statement,
std::int16_t &  count 
)
inlinenoexcept

Reports the number of columns of the current result set.

Parameters
statementThe statement.
countReceives the column count (0 for a statement that produced no result set).
Returns
The driver's result.

Definition at line 411 of file Dispatch.hpp.

References Lightweight::Driver::NumResultColumns().

Referenced by Lightweight::Driver::Odbc::NumResultColumns(), Lightweight::Driver::Sqlite3::NumResultColumns(), and Lightweight::Driver::NumResultColumns().

◆ NumParameters()

SqlResult Lightweight::Driver::NumParameters ( StatementHandle const &  statement,
std::int16_t &  count 
)
inlinenoexcept

Reports the number of parameters of the prepared statement.

Parameters
statementThe statement.
countReceives the parameter count.
Returns
The driver's result.

Definition at line 420 of file Dispatch.hpp.

References Lightweight::Driver::NumParameters().

Referenced by Lightweight::Driver::Odbc::NumParameters(), Lightweight::Driver::Sqlite3::NumParameters(), and Lightweight::Driver::NumParameters().

◆ NumRowsAffected()

SqlResult Lightweight::Driver::NumRowsAffected ( StatementHandle const &  statement,
std::ptrdiff_t &  count 
)
inlinenoexcept

Reports the number of rows the last executed statement affected.

Parameters
statementThe statement.
countReceives the row count; -1 when the driver cannot tell.
Returns
The driver's result.

Definition at line 429 of file Dispatch.hpp.

References Lightweight::Driver::NumRowsAffected().

Referenced by Lightweight::Driver::Odbc::NumRowsAffected(), Lightweight::Driver::Sqlite3::NumRowsAffected(), and Lightweight::Driver::NumRowsAffected().

◆ ColumnType()

std::expected< SqlResultColumnType, SqlErrorInfo > Lightweight::Driver::ColumnType ( StatementHandle const &  statement,
SqlColumnIndex  column 
)
inline

The SQL data type of a result column, as the driver describes it.

Parameters
statementThe statement, with a result set.
columnThe 1-based result column.
Returns
The type, SqlResultColumnType::Unknown for a type without an enumerator, or the statement's diagnostics if the column cannot be described.

Definition at line 439 of file Dispatch.hpp.

References Lightweight::Driver::ColumnType().

Referenced by Lightweight::Driver::Odbc::ColumnType(), Lightweight::Driver::Sqlite3::ColumnType(), and Lightweight::Driver::ColumnType().

◆ SetQueryTimeout()

SqlResult Lightweight::Driver::SetQueryTimeout ( StatementHandle &  statement,
std::chrono::seconds  timeout 
)
inlinenoexcept

Sets the query timeout of the statement.

Parameters
statementThe statement.
timeoutThe timeout; zero means none.
Returns
The driver's result.

Definition at line 449 of file Dispatch.hpp.

References Lightweight::Driver::SetQueryTimeout().

Referenced by Lightweight::Driver::Odbc::SetQueryTimeout(), Lightweight::Driver::Sqlite3::SetQueryTimeout(), and Lightweight::Driver::SetQueryTimeout().

◆ QueryTimeout()

SqlResult Lightweight::Driver::QueryTimeout ( StatementHandle const &  statement,
std::chrono::seconds &  timeout 
)
inlinenoexcept

Reports the query timeout of the statement.

Parameters
statementThe statement.
timeoutReceives the timeout; zero means none.
Returns
The driver's result.

Definition at line 458 of file Dispatch.hpp.

References Lightweight::Driver::QueryTimeout().

Referenced by Lightweight::Driver::Odbc::QueryTimeout(), Lightweight::Driver::Sqlite3::QueryTimeout(), and Lightweight::Driver::QueryTimeout().

◆ Diagnose()

SqlErrorInfo Lightweight::Driver::Diagnose ( StatementHandle const &  statement)
inline

Reads the statement's diagnostics: the first record its last failed call left.

Parameters
statementThe statement.
Returns
The diagnostics; value-initialized fields when the driver has none to report.

Definition at line 466 of file Dispatch.hpp.

References Lightweight::Driver::Diagnose().

Referenced by Lightweight::Driver::Sqlite3::Diagnose(), Lightweight::Driver::Diagnose(), and Lightweight::Driver::Odbc::ThrowBoundValueNotReadable().

◆ RequireSuccess()

void Lightweight::Driver::RequireSuccess ( StatementHandle const &  statement,
SqlResult  result,
std::source_location  location = std::source_location::current() 
)
inline

Throws unless result indicates success: std::invalid_argument for a soft failure the caller is expected to recover from, SqlException otherwise (see ClassifyResult).

Parameters
statementThe statement result came from.
resultThe result to check.
locationWhere the check originated; the driver's fault seam sees it. Defaults to the caller's location.

Definition at line 477 of file Dispatch.hpp.

References Lightweight::Driver::RequireSuccess().

Referenced by Lightweight::Driver::Sqlite3::RequireSuccess(), and Lightweight::Driver::RequireSuccess().

◆ CheckResult() [1/2]

CallOutcome Lightweight::Driver::CheckResult ( StatementHandle const &  statement,
SqlResult  result,
std::source_location  location 
)
inline

The non-throwing, fault-seam-aware verdict on result.

Parameters
statementThe statement result came from.
resultThe result to check.
locationWhere the check originated; the driver's fault seam sees it.
Returns
The verdict, plus the injected diagnostic when one was injected.

Definition at line 489 of file Dispatch.hpp.

References Lightweight::Driver::CheckResult().

Referenced by Lightweight::Driver::Sqlite3::CheckResult(), Lightweight::Driver::Odbc::CheckResult(), Lightweight::Driver::CheckResult(), Lightweight::Driver::Sqlite3::CheckResult(), Lightweight::Driver::Odbc::CheckResult(), and Lightweight::Driver::CheckResult().

◆ OpenCatalog()

SqlResult Lightweight::Driver::OpenCatalog ( StatementHandle const &  statement,
SqlCatalogRequest const &  request 
)
inline

Opens the catalog result set request names on statement, in the layout the ODBC specification gives that catalog function.

Parameters
statementThe statement to open the result set on.
requestThe catalog function and its arguments.
Returns
The driver's result; on a driver without catalog functions SqlResult::Error, with the statement's diagnostics NotSupportedByDriver(id, "catalog access") (SQLSTATE IM001).

Definition at line 502 of file Dispatch.hpp.

References Lightweight::Driver::OpenCatalog().

Referenced by Lightweight::Driver::Odbc::OpenCatalog(), Lightweight::Driver::Sqlite3::OpenCatalog(), and Lightweight::Driver::OpenCatalog().

◆ CatalogColumnType()

SqlResultColumnType Lightweight::Driver::CatalogColumnType ( StatementHandle const &  statement,
int  dataType 
)
inlinenoexcept

The type a DATA_TYPE code of the driver's catalog result sets (see OpenCatalog) stands for.

Parameters
statementThe statement holding the catalog result set.
dataTypeThe code, as read from the result set.
Returns
The type; SqlResultColumnType::Unknown for a code without an enumerator, and on a driver without catalog functions.

Definition at line 512 of file Dispatch.hpp.

References Lightweight::Driver::CatalogColumnType().

Referenced by Lightweight::Driver::Odbc::CatalogColumnType(), Lightweight::Driver::Sqlite3::CatalogColumnType(), and Lightweight::Driver::CatalogColumnType().

◆ DescribeColumn()

SqlResult Lightweight::Driver::DescribeColumn ( StatementHandle const &  statement,
SqlColumnIndex  column,
SqlColumnDescription &  description 
)
inline

Describes a result column: its type and its size.

Parameters
statementThe statement, with a result set.
columnThe 1-based result column.
descriptionReceives the description.
Returns
The driver's result.

Definition at line 522 of file Dispatch.hpp.

References Lightweight::Driver::DescribeColumn().

Referenced by Lightweight::Driver::Odbc::DeclaredBoundColumnSize(), Lightweight::Driver::Odbc::DescribeColumn(), Lightweight::Driver::Sqlite3::DescribeColumn(), Lightweight::Driver::Odbc::DescribeColumn(), and Lightweight::Driver::DescribeColumn().

◆ DescribeResultColumnSqlType()

std::optional< std::int16_t > Lightweight::Driver::DescribeResultColumnSqlType ( StatementHandle const &  statement,
SqlColumnIndex  column 
)
inlinenoexcept

The driver's own SQL type code of a result column, as the driver's leaf binders read it (see SqlDataBinderCallback::DescribeResultColumnType).

Parameters
statementThe statement, with a result set.
columnThe 1-based result column.
Returns
The code; std::nullopt when the driver cannot describe the column, or has no such codes (its binders then never ask).

Definition at line 535 of file Dispatch.hpp.

References Lightweight::Driver::DescribeResultColumnSqlType().

Referenced by Lightweight::Driver::Odbc::DescribeResultColumnSqlType(), Lightweight::Driver::Odbc::DescribeResultColumnSqlType(), Lightweight::Driver::Odbc::DescribeResultColumnSqlType(), Lightweight::Driver::Sqlite3::DescribeResultColumnSqlType(), and Lightweight::Driver::DescribeResultColumnSqlType().

◆ DeclaredBoundColumnSize()

std::size_t Lightweight::Driver::DeclaredBoundColumnSize ( StatementHandle const &  statement,
SqlColumnIndex  column,
SqlOutputColumnLength  length 
)
inlinenoexcept

The declared length of a result column as a bound buffer size (see SqlDataBinderCallback::MinimumOutputColumnSize).

Parameters
statementThe statement holding the result set.
columnThe 1-based result column.
lengthWhich declared length to ask for.
Returns
The number of elements to bind, without a terminator; detail::DefaultBoundColumnSize where the driver reports no usable length.

Definition at line 548 of file Dispatch.hpp.

References Lightweight::Driver::DeclaredBoundColumnSize().

Referenced by Lightweight::Driver::Odbc::DeclaredBoundColumnSize(), Lightweight::Driver::Sqlite3::DeclaredBoundColumnSize(), and Lightweight::Driver::DeclaredBoundColumnSize().

◆ ResetRowArrayAttributes()

void Lightweight::Driver::ResetRowArrayAttributes ( StatementHandle &  statement)
inlinenoexcept

Restores single-row fetching after a row-array fetch. Not reported; nothing for a driver without row arrays.

Parameters
statementThe statement.

Definition at line 558 of file Dispatch.hpp.

References Lightweight::Driver::ResetRowArrayAttributes().

Referenced by Lightweight::Driver::Odbc::ResetRowArrayAttributes(), Lightweight::Driver::Sqlite3::ResetRowArrayAttributes(), and Lightweight::Driver::ResetRowArrayAttributes().

◆ Allocate()

void Lightweight::Driver::Allocate ( ConnectionHandle &  connection)
inlinenoexcept

Allocates the driver's connection resources, unless the connection already holds them.

Parameters
connectionThe connection, bound to its driver.

Definition at line 569 of file Dispatch.hpp.

References Lightweight::Driver::Allocate().

Referenced by Lightweight::Driver::Odbc::Allocate(), Lightweight::Driver::Sqlite3::Allocate(), Lightweight::Driver::Odbc::Allocate(), Lightweight::Driver::Sqlite3::Allocate(), Lightweight::Driver::Allocate(), and Lightweight::Driver::AllocateStatement().

◆ Close()

std::expected< void, SqlErrorInfo > Lightweight::Driver::Close ( ConnectionHandle &  connection,
CloseDiagnostic  diagnostic 
)
inlinenoexcept

Closes the connection: disconnects it, frees its driver resources and leaves connection empty, bound to the same driver. Not reported.

Parameters
connectionThe connection; it must own its resources (not be borrowed).
diagnosticWhether a refused disconnect's diagnostic is read (Skip for a connection never opened).
Returns
Nothing, or the driver's diagnostic of a disconnect it refused, when read (the resources are freed regardless).

Definition at line 580 of file Dispatch.hpp.

References Lightweight::Driver::Close().

Referenced by Lightweight::Driver::BindDriverFor(), Lightweight::Driver::Odbc::Close(), Lightweight::Driver::Sqlite3::Close(), and Lightweight::Driver::Close().

◆ Disconnect()

SqlResult Lightweight::Driver::Disconnect ( ConnectionHandle &  connection)
inlinenoexcept

Ends the connection's session, keeping its driver resources for the next connect.

Parameters
connectionThe connection; one that holds no session has nothing to end.
Returns
The driver's result; a failure means the driver refused, and the session goes on.

Definition at line 589 of file Dispatch.hpp.

References Lightweight::Driver::Disconnect().

Referenced by Lightweight::Driver::Odbc::Disconnect(), Lightweight::Driver::Sqlite3::Disconnect(), and Lightweight::Driver::Disconnect().

◆ IsAllocated()

bool Lightweight::Driver::IsAllocated ( ConnectionHandle const &  connection)
inlinenoexcept

Tells whether connection holds a driver connection (connected or not).

Parameters
connectionThe connection.
Returns
Whether the driver connection is allocated.

Definition at line 597 of file Dispatch.hpp.

References Lightweight::Driver::IsAllocated().

Referenced by Lightweight::Driver::Odbc::IsAllocated(), Lightweight::Driver::Sqlite3::IsAllocated(), and Lightweight::Driver::IsAllocated().

◆ IsAlive()

bool Lightweight::Driver::IsAlive ( ConnectionHandle const &  connection)
inlinenoexcept

Tells whether the driver still considers the connection alive.

Parameters
connectionThe connection.
Returns
Whether the connection is alive.

Definition at line 605 of file Dispatch.hpp.

References Lightweight::Driver::IsAlive().

Referenced by Lightweight::Driver::Odbc::IsAlive(), Lightweight::Driver::Sqlite3::IsAlive(), and Lightweight::Driver::IsAlive().

◆ LastError()

SqlErrorInfo Lightweight::Driver::LastError ( ConnectionHandle const &  connection)
inline

Reads the connection's diagnostics: the first record its last failed call left.

Parameters
connectionThe connection.
Returns
The diagnostics; value-initialized fields when the driver has none to report.

Definition at line 613 of file Dispatch.hpp.

References Lightweight::Driver::LastError().

Referenced by Lightweight::Driver::Odbc::LastError(), Lightweight::Driver::Sqlite3::LastError(), and Lightweight::Driver::LastError().

◆ CheckResult() [2/2]

CallOutcome Lightweight::Driver::CheckResult ( ConnectionHandle const &  connection,
SqlResult  result,
std::source_location  location 
)
inline

The non-throwing, fault-seam-aware verdict on result of a call on connection.

Parameters
connectionThe connection result came from.
resultThe result to check.
locationWhere the check originated; the driver's fault seam sees it.
Returns
The verdict, plus the injected diagnostic when one was injected.

Definition at line 623 of file Dispatch.hpp.

References Lightweight::Driver::CheckResult().

◆ ServerName()

std::string Lightweight::Driver::ServerName ( ConnectionHandle const &  connection)
inline

The name of the DBMS the connection is connected to.

Parameters
connectionThe connected connection.
Returns
The name in UTF-8, or an empty string if the driver cannot tell.

Definition at line 633 of file Dispatch.hpp.

References Lightweight::Driver::ServerName().

Referenced by Lightweight::Driver::Odbc::ServerName(), Lightweight::Driver::Sqlite3::ServerName(), and Lightweight::Driver::ServerName().

◆ ServerVersion()

std::string Lightweight::Driver::ServerVersion ( ConnectionHandle const &  connection)
inline

The version of the DBMS the connection is connected to.

Parameters
connectionThe connected connection.
Returns
The version in UTF-8, or an empty string if the driver cannot tell.

Definition at line 641 of file Dispatch.hpp.

References Lightweight::Driver::ServerVersion().

Referenced by Lightweight::Driver::Odbc::ServerVersion(), Lightweight::Driver::Sqlite3::ServerVersion(), and Lightweight::Driver::ServerVersion().

◆ DriverName()

std::string Lightweight::Driver::DriverName ( ConnectionHandle const &  connection)
inline

The name of the driver (library) the connection runs on.

Parameters
connectionThe connected connection.
Returns
The name in UTF-8, or an empty string if the driver cannot tell.

Definition at line 649 of file Dispatch.hpp.

References Lightweight::Driver::DriverName().

Referenced by Lightweight::Driver::Odbc::DriverName(), Lightweight::Driver::Sqlite3::DriverName(), and Lightweight::Driver::DriverName().

◆ DatabaseName()

std::string Lightweight::Driver::DatabaseName ( ConnectionHandle const &  connection)
inline

The name of the database in use.

Parameters
connectionThe connected connection.
Returns
The name in UTF-8, or an empty string if the driver cannot tell.

Definition at line 657 of file Dispatch.hpp.

References Lightweight::Driver::DatabaseName().

Referenced by Lightweight::Driver::Odbc::DatabaseName(), Lightweight::Driver::Sqlite3::DatabaseName(), and Lightweight::Driver::DatabaseName().

◆ UserName()

std::string Lightweight::Driver::UserName ( ConnectionHandle const &  connection)
inline

The name of the user the connection is logged in as.

Parameters
connectionThe connected connection.
Returns
The name in UTF-8, or an empty string if the driver cannot tell.

Definition at line 665 of file Dispatch.hpp.

References Lightweight::Driver::UserName().

Referenced by Lightweight::Driver::Odbc::UserName(), Lightweight::Driver::Sqlite3::UserName(), and Lightweight::Driver::UserName().

◆ TransactionActive()

bool Lightweight::Driver::TransactionActive ( ConnectionHandle const &  connection)
inlinenoexcept

Tells whether a transaction is open, i.e. autocommit is off.

Parameters
connectionThe connection.
Returns
Whether a transaction is open.

Definition at line 673 of file Dispatch.hpp.

References Lightweight::Driver::TransactionActive().

Referenced by Lightweight::Driver::Odbc::TransactionActive(), Lightweight::Driver::Sqlite3::TransactionActive(), and Lightweight::Driver::TransactionActive().

◆ TransactionsAllowed()

bool Lightweight::Driver::TransactionsAllowed ( ConnectionHandle const &  connection)
inlinenoexcept

Tells whether the data source supports transactions.

Parameters
connectionThe connected connection.
Returns
Whether transactions are supported.

Definition at line 681 of file Dispatch.hpp.

References Lightweight::Driver::TransactionsAllowed().

Referenced by Lightweight::Driver::Odbc::TransactionsAllowed(), Lightweight::Driver::Sqlite3::TransactionsAllowed(), and Lightweight::Driver::TransactionsAllowed().

◆ SetAutoCommit()

SqlResult Lightweight::Driver::SetAutoCommit ( ConnectionHandle &  connection,
bool  enabled 
)
inlinenoexcept

Switches autocommit mode on or off.

Parameters
connectionThe connection.
enabledWhether every statement commits on its own.
Returns
The driver's result.

Definition at line 690 of file Dispatch.hpp.

References Lightweight::Driver::SetAutoCommit().

Referenced by Lightweight::Driver::Odbc::SetAutoCommit(), Lightweight::Driver::Sqlite3::SetAutoCommit(), and Lightweight::Driver::SetAutoCommit().

◆ Commit()

SqlResult Lightweight::Driver::Commit ( ConnectionHandle &  connection)
inlinenoexcept

Commits the open transaction.

Parameters
connectionThe connection.
Returns
The driver's result.

Definition at line 698 of file Dispatch.hpp.

References Lightweight::Driver::Commit().

Referenced by Lightweight::Driver::Odbc::Commit(), Lightweight::Driver::Sqlite3::Commit(), and Lightweight::Driver::Commit().

◆ Rollback()

SqlResult Lightweight::Driver::Rollback ( ConnectionHandle &  connection)
inlinenoexcept

Rolls back the open transaction.

Parameters
connectionThe connection.
Returns
The driver's result.

Definition at line 706 of file Dispatch.hpp.

References Lightweight::Driver::Rollback().

Referenced by Lightweight::Driver::Odbc::Rollback(), Lightweight::Driver::Sqlite3::Rollback(), and Lightweight::Driver::Rollback().

◆ SetIsolation()

SqlResult Lightweight::Driver::SetIsolation ( ConnectionHandle &  connection,
SqlIsolationMode  mode 
)
inlinenoexcept

Sets the transaction isolation level of the connection.

Parameters
connectionThe connection.
modeThe isolation level; not SqlIsolationMode::DriverDefault.
Returns
The driver's result.

Definition at line 715 of file Dispatch.hpp.

References Lightweight::Driver::SetIsolation().

Referenced by Lightweight::Driver::Odbc::SetIsolation(), Lightweight::Driver::Sqlite3::SetIsolation(), and Lightweight::Driver::SetIsolation().

◆ RollbackOpenTransaction()

bool Lightweight::Driver::RollbackOpenTransaction ( ConnectionHandle &  connection)
inlinenoexcept

Rolls back the open transaction and switches autocommit back on.

Parameters
connectionThe connection, with a transaction open.
Returns
Whether both steps succeeded.

Definition at line 723 of file Dispatch.hpp.

References Lightweight::Driver::RollbackOpenTransaction().

Referenced by Lightweight::Driver::Odbc::RollbackOpenTransaction(), Lightweight::Driver::Sqlite3::RollbackOpenTransaction(), and Lightweight::Driver::RollbackOpenTransaction().

◆ SearchPatternEscape()

std::expected< std::string, SqlErrorInfo > Lightweight::Driver::SearchPatternEscape ( ConnectionHandle const &  connection)
inline

The string the driver escapes the wildcards of a catalog search pattern with (see OpenCatalog).

Parameters
connectionThe connected connection.
Returns
The escape, empty when the driver reports none; on a driver without catalog functions NotSupportedByDriver(id, "catalog access") (SQLSTATE IM001).

Definition at line 732 of file Dispatch.hpp.

◆ RebindsDriverFor()

template<typename Info >
bool Lightweight::Driver::RebindsDriverFor ( ConnectionHandle const &  handle)
noexcept

Tells whether connecting from Info binds handle to another driver than the one it is bound to.

Parameters
handleThe connection's handle.
Returns
true when an enabled driver connects from Info and it is not the handle's; false otherwise, also when no enabled driver connects from Info.

Definition at line 746 of file Dispatch.hpp.

References Lightweight::Driver::RebindsDriverFor().

Referenced by Lightweight::Driver::RebindsDriverFor().

◆ BindDriverFor()

template<typename Info >
void Lightweight::Driver::BindDriverFor ( ConnectionHandle &  handle)
noexcept

Binds handle to the enabled driver D for which Connect(D::Connection&, Info const&, std::source_location) is well-formed (found by argument-dependent lookup), closing what the handle held if that was another driver's. No such driver: no change.

Parameters
handleThe connection's handle; it must own what it holds (not be borrowed).

Definition at line 760 of file Dispatch.hpp.

References Lightweight::Driver::BindDriverFor(), and Lightweight::Driver::Close().

Referenced by Lightweight::Driver::BindDriverFor().

◆ Connect()

template<typename Info >
std::expected< void, SqlErrorInfo > Lightweight::Driver::Connect ( ConnectionHandle &  handle,
Info const &  info,
std::source_location  location 
)

Connects handle from info through the enabled driver that connects from it.

Parameters
handleThe connection's handle, bound by BindDriverFor and allocated by Allocate.
infoWhat to connect from.
locationWhere the connect originated; the driver's fault seam sees it as the location of its connection checks.
Returns
Nothing on success, else the driver's diagnostics of the failed step. When no enabled driver connects from Info, or handle is bound to another driver: std::unexpected(NotSupportedByDriver(handle.DriverId(), "connecting from a <Info>")).

Definition at line 782 of file Dispatch.hpp.

References Lightweight::Driver::Connect().

Referenced by Lightweight::Driver::Odbc::Connect(), Lightweight::Driver::Odbc::Connect(), Lightweight::Driver::Sqlite3::Connect(), and Lightweight::Driver::Connect().

◆ AcceptsWideQueryText()

bool Lightweight::Driver::AcceptsWideQueryText ( ConnectionHandle const &  connection)
inlinenoexcept

Tells whether the connection's driver receives wide (UTF-16) query text unchanged.

Parameters
connectionThe connected connection.
Returns
The driver's answer; true for a driver without the operation.

Definition at line 805 of file Dispatch.hpp.

References Lightweight::Driver::AcceptsWideQueryText().

Referenced by Lightweight::Driver::Odbc::AcceptsWideQueryText(), and Lightweight::Driver::AcceptsWideQueryText().

◆ ReadsBoundColumnsAgain()

bool Lightweight::Driver::ReadsBoundColumnsAgain ( ConnectionHandle const &  connection)
inlinenoexcept

Tells whether the connection's driver can read a bound output column again, so that a bound value longer than its buffer is read in full (see SqlConnection::ReadsBoundColumnsAgain).

Parameters
connectionThe connected connection.
Returns
The driver's answer; true for a driver without the operation, which fills a bound column afresh for every row and so never cuts a value off.

Definition at line 820 of file Dispatch.hpp.

References Lightweight::Driver::ReadsBoundColumnsAgain().

Referenced by Lightweight::Driver::Odbc::ReadsBoundColumnsAgain(), and Lightweight::Driver::ReadsBoundColumnsAgain().

◆ NarrowTextBinding()

::Lightweight::detail::NarrowTextBinding Lightweight::Driver::NarrowTextBinding ( ConnectionHandle const &  connection,
SqlServerType  serverType,
SqlConnectInfo const &  connectInfo 
)
inline

Tells how the narrow string binders exchange text with the connection's driver (see SqlConnection::NarrowTextBindingMode).

Parameters
connectionThe connected connection.
serverTypeThe connected backend.
connectInfoWhat the connection was connected from.
Returns
The driver's answer; detail::NarrowTextBindingOf(serverType) for a driver without the operation.

Definition at line 836 of file Dispatch.hpp.

◆ DriverNameOf()

std::string Lightweight::Driver::DriverNameOf ( ConnectionHandle const &  connection,
SqlConnectionString const &  connectionString 
)
inline

Names the driver a connect from connectionString reaches, without connecting (see ServerTypeFromDriverName): the connection string's own DRIVER, else what the driver manager lists for its DSN.

Parameters
connectionThe connection, allocated.
connectionStringThe connection string to connect from.
Returns
The driver's answer; empty for a driver without the operation, or when nothing names the driver.

Definition at line 855 of file Dispatch.hpp.

References Lightweight::Driver::DriverNameOf().

Referenced by Lightweight::Driver::Odbc::DriverNameOf(), and Lightweight::Driver::DriverNameOf().

◆ RegisterTextEntry()

void Lightweight::Driver::RegisterTextEntry ( ConnectionHandle const &  connection,
bool  acceptsWideQueryText 
)
inlinenoexcept

Records whether the connection's driver takes text through its wide entry points, where the driver has such a choice; does nothing otherwise.

Parameters
connectionThe connected connection.
acceptsWideQueryTextWhat AcceptsWideQueryText found.

Definition at line 871 of file Dispatch.hpp.

References Lightweight::Driver::RegisterTextEntry().

Referenced by Lightweight::Driver::Odbc::RegisterTextEntry(), and Lightweight::Driver::RegisterTextEntry().

◆ RegisterAnsiOnly()

void Lightweight::Driver::RegisterAnsiOnly ( StatementHandle const &  statement,
ConnectionHandle const &  connection 
)
inlinenoexcept

Records statement as belonging to a connection whose driver takes text only through its ANSI entry points, where the driver has such a choice; does nothing otherwise.

Parameters
statementThe freshly allocated statement.
connectionThe connection it was allocated on.

Definition at line 883 of file Dispatch.hpp.

References Lightweight::Driver::RegisterAnsiOnly().

Referenced by Lightweight::Driver::Odbc::RegisterAnsiOnly(), and Lightweight::Driver::RegisterAnsiOnly().

◆ DescribeParameterTypes()

std::vector< std::int16_t > Lightweight::Driver::DescribeParameterTypes ( StatementHandle const &  statement,
std::size_t  count 
)
inline

Describes the declared SQL type of each of the first count parameters.

Parameters
statementThe prepared statement.
countThe number of parameters to describe.
Returns
The driver's type codes; empty for a driver without the operation.

Definition at line 897 of file Dispatch.hpp.

References Lightweight::Driver::DescribeParameterTypes().

Referenced by Lightweight::Driver::Odbc::DescribeParameterTypes(), and Lightweight::Driver::DescribeParameterTypes().

◆ BoundParameterCount()

std::int16_t Lightweight::Driver::BoundParameterCount ( StatementHandle const &  statement)
inlinenoexcept

The number of parameters currently bound on the statement.

Parameters
statementThe statement.
Returns
The driver's count; -1 for a driver without the operation, or when it cannot tell.

Definition at line 910 of file Dispatch.hpp.

References Lightweight::Driver::BoundParameterCount().

Referenced by Lightweight::Driver::Odbc::BoundParameterCount(), and Lightweight::Driver::BoundParameterCount().

◆ VisitIfSupported()

template<typename Handle , typename F >
requires detail::TaggedHandle<std::remove_cvref_t<Handle>>
void Lightweight::Driver::VisitIfSupported ( Handle &&  handle,
F &&  f 
)

Calls f with the held struct when f is invocable with it; otherwise does nothing.

Parameters
handleThe statement or connection handle.
fThe callable, e.g. taking one driver's struct only.

Definition at line 929 of file Dispatch.hpp.

References Lightweight::Driver::VisitIfSupported().

Referenced by Lightweight::Driver::VisitIfSupported().

◆ VisitRequired()

template<typename Handle , typename F >
requires detail::TaggedHandle<std::remove_cvref_t<Handle>>
decltype(auto) Lightweight::Driver::VisitRequired ( Handle &&  handle,
std::string_view  operation,
F &&  f 
)

Calls f with the held struct when invocable; otherwise throws SqlException(NotSupportedByDriver(id, operation)).

Parameters
handleThe statement or connection handle.
operationThe name of the operation f performs, for the error message.
fThe callable, e.g. taking one driver's struct only.
Returns
What f returns.

Definition at line 945 of file Dispatch.hpp.

References Lightweight::Driver::VisitRequired().

Referenced by Lightweight::Driver::Odbc::RestoreBoundBuffer(), and Lightweight::Driver::VisitRequired().

Variable Documentation

◆ RefusesUnsetDefaultConnectInfo

constexpr bool Lightweight::Driver::RefusesUnsetDefaultConnectInfo = !IsEnabled(SqlDriverId::Odbc)
inlineconstexpr

Whether a connection opened from the default connect info refuses to connect while no default was set (see SqlConnection::SetDefaultConnectInfo): with SQLSTATE 08001 instead of opening what the unset default names. Holds in a build without the ODBC driver, whose unset default would be a SqliteConnectInfo naming a private temporary database. With ODBC the unset default is an empty connection string, which the driver manager refuses itself.

Definition at line 207 of file Dispatch.hpp.