6#include "../SqlBindingTypes.hpp"
7#include "../SqlConnectInfo.hpp"
8#include "../SqlError.hpp"
9#include "../SqlServerType.hpp"
11#include "DriverSet.hpp"
21#include <source_location>
42namespace Lightweight::Driver
49 concept TaggedHandle = std::same_as<H, StatementHandle> || std::same_as<H, ConnectionHandle>;
58 constexpr auto FindFirstInvokeResult() noexcept -> std::type_identity<
void>
66 template <
typename F,
typename Arg,
typename... Rest>
67 constexpr auto FindFirstInvokeResult(std::type_identity<Arg> , std::type_identity<Rest>... rest)
noexcept
69 if constexpr (std::is_invocable_v<F, Arg>)
70 return std::type_identity<std::invoke_result_t<F, Arg>> {};
72 return FindFirstInvokeResult<F>(rest...);
77 template <
typename F,
typename Role,
typename... Drivers>
78 constexpr auto FindRequiredVisitResult(BasicHandle<Role, Drivers...>* )
noexcept
80 return FindFirstInvokeResult<F>(std::type_identity<
typename Role::template Type<Drivers>&> {}...);
85 template <
typename F,
typename Role,
typename... Drivers>
86 constexpr auto FindRequiredVisitResult(BasicHandle<Role, Drivers...>
const* )
noexcept
88 return FindFirstInvokeResult<F>(std::type_identity<
typename Role::template Type<Drivers>
const&> {}...);
92 template <
typename F,
typename Handle>
93 using RequiredVisitResult =
decltype(FindRequiredVisitResult<F>(
static_cast<Handle*
>(
nullptr)))::type;
97 template <
typename D,
typename Info>
98 concept DriverConnectsFrom =
requires(D::Connection& connection, Info
const& info, std::source_location location) {
99 {
Connect(connection, info, location) } -> std::same_as<std::expected<void, SqlErrorInfo>>;
104 template <
typename Info>
105 constexpr auto FindDriverConnectingFrom(DriverList<> )
noexcept -> std::type_identity<void>
112 template <
typename Info,
typename D,
typename... Rest>
113 constexpr auto FindDriverConnectingFrom(DriverList<D, Rest...> )
noexcept
115 if constexpr (DriverConnectsFrom<D, Info>)
116 return std::type_identity<D> {};
118 return FindDriverConnectingFrom<Info>(DriverList<Rest...> {});
122 template <
typename Info>
123 using EnabledDriverConnectingFrom =
decltype(FindDriverConnectingFrom<Info>(EnabledDrivers {}))::type;
126 template <
typename Info>
127 inline constexpr bool CanConnectFrom = !std::is_void_v<EnabledDriverConnectingFrom<Info>>;
131 template <
typename Info>
132 constexpr std::string_view ConnectInfoName() noexcept
134 static_assert(std::same_as<Info, SqliteConnectInfo>,
"Info must be one of the SqlConnectInfo alternatives.");
135 return "SqliteConnectInfo";
138#if defined(LIGHTWEIGHT_DRIVER_ODBC)
142 constexpr std::string_view ConnectInfoName<SqlConnectionString>() noexcept
144 return "SqlConnectionString";
150 constexpr std::string_view ConnectInfoName<SqlConnectionDataSource>() noexcept
152 return "SqlConnectionDataSource";
159 template <
typename Info>
160 [[nodiscard]] SqlErrorInfo ConnectNotSupported(SqlDriverId driver)
162 return NotSupportedByDriver(driver, std::format(
"connecting from a {}", ConnectInfoName<Info>()));
166 template <SqlDriver... Drivers>
167 constexpr bool IsEnabled(SqlDriverId
id, DriverList<Drivers...> )
noexcept
169 return ((Drivers::Id ==
id) || ...);
173 template <SqlDriver... Drivers>
174 constexpr std::string_view NameOf(SqlDriverId
id, DriverList<Drivers...> )
noexcept
176 auto name = std::string_view {
"unknown" };
177 (void) ((Drivers::Id ==
id ? (name = Drivers::Name,
true) : false) || ...);
185 template <
typename Select, SqlDriver... Drivers>
186 constexpr bool CapabilityOf(SqlDriverId
id, Select
const& select, DriverList<Drivers...> )
noexcept
188 auto supported =
false;
189 (void) ((Drivers::Id ==
id ? (supported = select(std::type_identity<Drivers> {}),
true) : false) || ...);
197[[nodiscard]]
constexpr bool IsEnabled(SqlDriverId
id)
noexcept
199 return detail::IsEnabled(
id, detail::EnabledDrivers {});
212[[nodiscard]]
constexpr std::string_view NameOf(SqlDriverId
id)
noexcept
214 return detail::NameOf(
id, detail::EnabledDrivers {});
222 return detail::CapabilityOf(
223 id, []<
typename D>(std::type_identity<D>) {
return D::SupportsParameterArrays; }, detail::EnabledDrivers {});
231 return detail::CapabilityOf(
232 id, []<
typename D>(std::type_identity<D>) {
return D::SupportsRowArrayFetch; }, detail::EnabledDrivers {});
241 return detail::CapabilityOf(
242 id, []<
typename D>(std::type_identity<D>) {
return D::StatementsDieWithConnection; }, detail::EnabledDrivers {});
251 return detail::CapabilityOf(
252 id, []<
typename D>(std::type_identity<D>) {
return D::TranscodesNarrowText; }, detail::EnabledDrivers {});
261 return detail::CapabilityOf(
262 id, []<
typename D>(std::type_identity<D>) {
return D::HasCatalogFunctions; }, detail::EnabledDrivers {});
272[[nodiscard]]
inline SqlResult
AllocateStatement(ConnectionHandle
const& connection, StatementHandle& statement)
noexcept
274 return Visit(connection, [&statement](
auto const& held) {
275 using D = detail::DriverOfConnection<std::remove_cvref_t<
decltype(held)>, detail::EnabledDrivers>;
276 auto driverStatement =
typename D::Statement {};
277 auto const result =
Allocate(held, driverStatement);
278 statement = StatementHandle { driverStatement };
285inline void Free(StatementHandle& statement)
noexcept
287 Visit(statement, [](
auto& held) {
Free(held); });
294inline void Abandon(StatementHandle& statement)
noexcept
296 Visit(statement, [](
auto& held) {
Abandon(held); });
303[[nodiscard]]
inline StatementHandle
Alias(StatementHandle
const& statement)
noexcept
305 return Visit(statement, [](
auto const& held) {
return StatementHandle { held }; });
312[[nodiscard]]
inline bool SameStatement(StatementHandle
const& first, StatementHandle
const& second)
noexcept
314 return Visit(first, [&second](
auto const& heldFirst) {
315 return Visit(second, [&heldFirst](
auto const& heldSecond) {
316 if constexpr (std::same_as<
decltype(heldFirst),
decltype(heldSecond)>)
317 return heldFirst == heldSecond;
330[[nodiscard]]
inline SqlResult
Prepare(StatementHandle& statement, std::string_view query,
bool wideQueryText)
332 return Visit(statement, [&](
auto& held) {
return Prepare(held, query, wideQueryText); });
338[[nodiscard]]
inline LIGHTWEIGHT_FORCE_INLINE SqlResult
Execute(StatementHandle& statement)
noexcept
340 return Visit(statement, [](
auto& held) {
return Execute(held); });
348[[nodiscard]]
inline SqlResult
ExecuteDirect(StatementHandle& statement, std::string_view query,
bool wideQueryText)
350 return Visit(statement, [&](
auto& held) {
return ExecuteDirect(held, query, wideQueryText); });
356[[nodiscard]]
inline LIGHTWEIGHT_FORCE_INLINE SqlResult
Fetch(StatementHandle& statement)
noexcept
358 return Visit(statement, [](
auto& held) {
return Fetch(held); });
364[[nodiscard]]
inline SqlResult
MoreResults(StatementHandle& statement)
noexcept
366 return Visit(statement, [](
auto& held) {
return MoreResults(held); });
373 Visit(statement, [](
auto& held) {
CloseCursor(held); });
387[[nodiscard]]
inline SqlResult
UnbindColumns(StatementHandle& statement)
noexcept
389 return Visit(statement, [](
auto& held) {
return UnbindColumns(held); });
397 return Visit(statement, [](
auto& held) {
return ResetParameters(held); });
411[[nodiscard]]
inline SqlResult
NumResultColumns(StatementHandle
const& statement, std::int16_t& count)
noexcept
413 return Visit(statement, [&count](
auto const& held) {
return NumResultColumns(held, count); });
420[[nodiscard]]
inline SqlResult
NumParameters(StatementHandle
const& statement, std::int16_t& count)
noexcept
422 return Visit(statement, [&count](
auto const& held) {
return NumParameters(held, count); });
429[[nodiscard]]
inline SqlResult
NumRowsAffected(StatementHandle
const& statement, std::ptrdiff_t& count)
noexcept
431 return Visit(statement, [&count](
auto const& held) {
return NumRowsAffected(held, count); });
439[[nodiscard]]
inline std::expected<SqlResultColumnType, SqlErrorInfo>
ColumnType(StatementHandle
const& statement,
440 SqlColumnIndex column)
442 return Visit(statement, [column](
auto const& held) {
return ColumnType(held, column); });
449[[nodiscard]]
inline SqlResult
SetQueryTimeout(StatementHandle& statement, std::chrono::seconds timeout)
noexcept
451 return Visit(statement, [timeout](
auto& held) {
return SetQueryTimeout(held, timeout); });
458[[nodiscard]]
inline SqlResult
QueryTimeout(StatementHandle
const& statement, std::chrono::seconds& timeout)
noexcept
460 return Visit(statement, [&timeout](
auto const& held) {
return QueryTimeout(held, timeout); });
468 return Visit(statement, [](
auto const& held) {
return Diagnose(held); });
479 std::source_location location = std::source_location::current())
481 Visit(statement, [&](
auto const& held) {
RequireSuccess(held, result, location); });
491 std::source_location location)
493 return Visit(statement, [&](
auto const& held) {
return CheckResult(held, result, location); });
504 return Visit(statement, [&request](
auto const& held) {
return OpenCatalog(held, request); });
512[[nodiscard]]
inline SqlResultColumnType
CatalogColumnType(StatementHandle
const& statement,
int dataType)
noexcept
514 return Visit(statement, [dataType](
auto const& held) {
return CatalogColumnType(held, dataType); });
523 SqlColumnIndex column,
526 return Visit(statement, [&](
auto const& held) {
return DescribeColumn(held, column, description); });
536 SqlColumnIndex column)
noexcept
549 SqlColumnIndex column,
550 SqlOutputColumnLength length)
noexcept
569inline void Allocate(ConnectionHandle& connection)
noexcept
571 Visit(connection, [](
auto& held) {
Allocate(held); });
580[[nodiscard]]
inline std::expected<void, SqlErrorInfo>
Close(ConnectionHandle& connection,
581 CloseDiagnostic diagnostic)
noexcept
583 return Visit(connection, [diagnostic](
auto& held) {
return Close(held, diagnostic); });
589[[nodiscard]]
inline SqlResult
Disconnect(ConnectionHandle& connection)
noexcept
591 return Visit(connection, [](
auto& held) {
return Disconnect(held); });
597[[nodiscard]]
inline bool IsAllocated(ConnectionHandle
const& connection)
noexcept
599 return Visit(connection, [](
auto const& held) {
return IsAllocated(held); });
605[[nodiscard]]
inline bool IsAlive(ConnectionHandle
const& connection)
noexcept
607 return Visit(connection, [](
auto const& held) {
return IsAlive(held); });
615 return Visit(connection, [](
auto const& held) {
return LastError(held); });
625 std::source_location location)
627 return Visit(connection, [&](
auto const& held) {
return CheckResult(held, result, location); });
633[[nodiscard]]
inline std::string
ServerName(ConnectionHandle
const& connection)
635 return Visit(connection, [](
auto const& held) {
return ServerName(held); });
641[[nodiscard]]
inline std::string
ServerVersion(ConnectionHandle
const& connection)
643 return Visit(connection, [](
auto const& held) {
return ServerVersion(held); });
649[[nodiscard]]
inline std::string
DriverName(ConnectionHandle
const& connection)
651 return Visit(connection, [](
auto const& held) {
return DriverName(held); });
657[[nodiscard]]
inline std::string
DatabaseName(ConnectionHandle
const& connection)
659 return Visit(connection, [](
auto const& held) {
return DatabaseName(held); });
665[[nodiscard]]
inline std::string
UserName(ConnectionHandle
const& connection)
667 return Visit(connection, [](
auto const& held) {
return UserName(held); });
675 return Visit(connection, [](
auto const& held) {
return TransactionActive(held); });
690[[nodiscard]]
inline SqlResult
SetAutoCommit(ConnectionHandle& connection,
bool enabled)
noexcept
692 return Visit(connection, [enabled](
auto& held) {
return SetAutoCommit(held, enabled); });
698[[nodiscard]]
inline SqlResult
Commit(ConnectionHandle& connection)
noexcept
700 return Visit(connection, [](
auto& held) {
return Commit(held); });
706[[nodiscard]]
inline SqlResult
Rollback(ConnectionHandle& connection)
noexcept
708 return Visit(connection, [](
auto& held) {
return Rollback(held); });
715[[nodiscard]]
inline SqlResult
SetIsolation(ConnectionHandle& connection, SqlIsolationMode mode)
noexcept
717 return Visit(connection, [mode](
auto& held) {
return SetIsolation(held, mode); });
732[[nodiscard]]
inline std::expected<std::string, SqlErrorInfo> SearchPatternEscape(ConnectionHandle
const& connection)
734 return Visit(connection, [](
auto const& held) {
return SearchPatternEscape(held); });
745template <
typename Info>
748 using D = detail::EnabledDriverConnectingFrom<Info>;
749 if constexpr (std::is_void_v<D>)
752 return handle.DriverId() != D::Id;
759template <
typename Info>
762 using D = detail::EnabledDriverConnectingFrom<Info>;
763 if constexpr (!std::is_void_v<D>)
765 if (handle.DriverId() == D::Id)
767 if (!handle.IsEmpty())
768 std::ignore =
Close(handle, CloseDiagnostic::Skip);
769 handle = ConnectionHandle {
typename D::Connection {} };
781template <
typename Info>
782[[nodiscard]] std::expected<void, SqlErrorInfo>
Connect(ConnectionHandle& handle,
784 std::source_location location)
786 using D = detail::EnabledDriverConnectingFrom<Info>;
787 if constexpr (std::is_void_v<D>)
788 return std::unexpected(detail::ConnectNotSupported<Info>(handle.DriverId()));
790 return Visit(handle, [&](
auto& held) -> std::expected<void, SqlErrorInfo> {
791 if constexpr (std::same_as<std::remove_cvref_t<
decltype(held)>,
typename D::Connection>)
792 return Connect(held, info, location);
794 return std::unexpected(detail::ConnectNotSupported<Info>(handle.DriverId()));
807 return Visit(connection, [](
auto const& held) {
822 return Visit(connection, [](
auto const& held) {
836[[nodiscard]] inline ::Lightweight::detail::NarrowTextBinding NarrowTextBinding(ConnectionHandle
const& connection,
837 SqlServerType serverType,
840 return Visit(connection, [&](
auto const& held) {
841 if constexpr (
requires { NarrowTextBinding(held, serverType, connectInfo); })
842 return NarrowTextBinding(held, serverType, connectInfo);
844 return ::Lightweight::detail::NarrowTextBindingOf(serverType);
848#if defined(LIGHTWEIGHT_DRIVER_ODBC)
855[[nodiscard]]
inline std::string
DriverNameOf(ConnectionHandle
const& connection,
858 return Visit(connection, [&](
auto const& held) -> std::string {
859 if constexpr (
requires {
DriverNameOf(held, connectionString); })
871inline void RegisterTextEntry(ConnectionHandle
const& connection,
bool acceptsWideQueryText)
noexcept
873 Visit(connection, [acceptsWideQueryText](
auto const& held) {
883inline void RegisterAnsiOnly(StatementHandle
const& statement, ConnectionHandle
const& connection)
noexcept
885 Visit(statement, [&connection](
auto const& heldStatement) {
886 Visit(connection, [&heldStatement](
auto const& heldConnection) {
887 if constexpr (
requires {
RegisterAnsiOnly(heldStatement, heldConnection); })
897[[nodiscard]]
inline std::vector<std::int16_t>
DescribeParameterTypes(StatementHandle
const& statement, std::size_t count)
899 return Visit(statement, [count](
auto const& held) {
903 return std::vector<std::int16_t> {};
912 return Visit(statement, [](
auto const& held) {
916 return std::int16_t { -1 };
927template <
typename Handle,
typename F>
928 requires detail::TaggedHandle<std::remove_cvref_t<Handle>>
931 Visit(std::forward<Handle>(handle), [&f](
auto& held) {
932 if constexpr (std::is_invocable_v<F,
decltype(held)>)
933 std::invoke(std::forward<F>(f), held);
943template <
typename Handle,
typename F>
944 requires detail::TaggedHandle<std::remove_cvref_t<Handle>>
945decltype(
auto)
VisitRequired(Handle&& handle, std::string_view operation, F&& f)
948 using Visited = std::conditional_t<std::is_lvalue_reference_v<Handle>,
949 std::remove_reference_t<Handle>,
950 std::remove_reference_t<Handle>
const>;
951 using Result = detail::RequiredVisitResult<F, Visited>;
952 auto const driverId = handle.DriverId();
953 return Visit(std::forward<Handle>(handle), [&](
auto& held) -> Result {
954 if constexpr (std::is_invocable_v<F,
decltype(held)>)
955 return std::invoke(std::forward<F>(f), held);
957 throw SqlException(NotSupportedByDriver(driverId, operation));
bool IsAllocated(ConnectionHandle const &connection) noexcept
Tells whether connection holds a driver connection (connected or not).
std::string ServerVersion(ConnectionHandle const &connection)
The version of the DBMS the connection is connected to.
void ResetParameterArrays(StatementHandle &statement) noexcept
Restores single-row parameter binding after a parameter-array execution. Not reported.
void CloseCursor(StatementHandle &statement) noexcept
Closes the cursor of a result set that was read to its end. Pending result sets are left alone.
std::expected< void, SqlErrorInfo > Connect(ConnectionHandle &handle, Info const &info, std::source_location location)
Connects handle from info through the enabled driver that connects from it.
SqlResult UnbindColumns(StatementHandle &statement) noexcept
Unbinds every bound result column.
bool TransactionActive(ConnectionHandle const &connection) noexcept
Tells whether a transaction is open, i.e. autocommit is off.
constexpr bool StatementsDieWithConnection(SqlDriverId id) noexcept
Whether closing a connection of an enabled driver destroys its statement handles, so that they must n...
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...
decltype(auto) VisitRequired(Handle &&handle, std::string_view operation, F &&f)
Calls f with the held struct when invocable; otherwise throws SqlException(NotSupportedByDriver(id,...
void Allocate(ConnectionHandle &connection) noexcept
Allocates the driver's connection resources, unless the connection already holds them.
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...
SqlResult SetAutoCommit(ConnectionHandle &connection, bool enabled) noexcept
Switches autocommit mode on or off.
bool SameStatement(StatementHandle const &first, StatementHandle const &second) noexcept
Tells whether two handles name the same driver statement.
constexpr bool SupportsParameterArrays(SqlDriverId id) noexcept
Whether an enabled driver executes parameter arrays natively (one call per batch).
SqlResult NumResultColumns(StatementHandle const &statement, std::int16_t &count) noexcept
Reports the number of columns of the current result set.
bool ReadsBoundColumnsAgain(ConnectionHandle const &connection) noexcept
Tells whether the connection's driver can read a bound output column again, so that a bound value lon...
std::string ServerName(ConnectionHandle const &connection)
The name of the DBMS the connection is connected to.
SqlResult SetQueryTimeout(StatementHandle &statement, std::chrono::seconds timeout) noexcept
Sets the query timeout of the statement.
constexpr bool SupportsRowArrayFetch(SqlDriverId id) noexcept
Whether an enabled driver fetches blocks of rows into array-bound columns natively.
constexpr bool HasCatalogFunctions(SqlDriverId id) noexcept
Whether an enabled driver reads a database's catalog with catalog functions of its own (ODBC's SQLTab...
void DiscardResults(StatementHandle &statement) noexcept
Drains every pending result set and closes the cursor, so the handle can run another query....
void Free(StatementHandle &statement) noexcept
Frees the statement's driver handle and leaves statement empty, bound to the same driver.
std::string DriverNameOf(ConnectionHandle const &connection, SqlConnectionString const &connectionString)
Names the driver a connect from connectionString reaches, without connecting (see ServerTypeFromDrive...
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...
void RegisterAnsiOnly(StatementHandle const &statement, ConnectionHandle const &connection) noexcept
Records statement as belonging to a connection whose driver takes text only through its ANSI entry po...
SqlResult NumParameters(StatementHandle const &statement, std::int16_t &count) noexcept
Reports the number of parameters of the prepared statement.
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.
SqlResult SetIsolation(ConnectionHandle &connection, SqlIsolationMode mode) noexcept
Sets the transaction isolation level of the connection.
constexpr bool RefusesUnsetDefaultConnectInfo
Whether a connection opened from the default connect info refuses to connect while no default was set...
SqlResult QueryTimeout(StatementHandle const &statement, std::chrono::seconds &timeout) noexcept
Reports the query timeout of the statement.
void ResetRowArrayAttributes(StatementHandle &statement) noexcept
Restores single-row fetching after a row-array fetch. Not reported; nothing for a driver without row ...
SqlResult NumRowsAffected(StatementHandle const &statement, std::ptrdiff_t &count) noexcept
Reports the number of rows the last executed statement affected.
bool RebindsDriverFor(ConnectionHandle const &handle) noexcept
Tells whether connecting from Info binds handle to another driver than the one it is bound to.
void Abandon(StatementHandle &statement) noexcept
Gives up the statement's driver handle after its connection session ended, and leaves statement empty...
bool RollbackOpenTransaction(ConnectionHandle &connection) noexcept
Rolls back the open transaction and switches autocommit back on.
SqlErrorInfo LastError(ConnectionHandle const &connection)
Reads the connection's diagnostics: the first record its last failed call left.
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...
SqlResult Disconnect(ConnectionHandle &connection) noexcept
Ends the connection's session, keeping its driver resources for the next connect.
StatementHandle Alias(StatementHandle const &statement) noexcept
A second handle naming the same driver statement as statement (its driver struct copied,...
SqlResult Commit(ConnectionHandle &connection) noexcept
Commits the open transaction.
void VisitIfSupported(Handle &&handle, F &&f)
Calls f with the held struct when f is invocable with it; otherwise does nothing.
SqlErrorInfo Diagnose(StatementHandle const &statement)
Reads the statement's diagnostics: the first record its last failed call left.
std::int16_t BoundParameterCount(StatementHandle const &statement) noexcept
The number of parameters currently bound on the statement.
std::string DriverName(ConnectionHandle const &connection)
The name of the driver (library) the connection runs on.
void RegisterTextEntry(ConnectionHandle const &connection, bool acceptsWideQueryText) noexcept
Records whether the connection's driver takes text through its wide entry points, where the driver ha...
SqlResult DescribeColumn(StatementHandle const &statement, SqlColumnIndex column, SqlColumnDescription &description)
Describes a result column: its type and its size.
SqlResult ResetParameters(StatementHandle &statement) noexcept
Drops every parameter binding.
std::expected< SqlResultColumnType, SqlErrorInfo > ColumnType(StatementHandle const &statement, SqlColumnIndex column)
The SQL data type of a result column, as the driver describes it.
void BindDriverFor(ConnectionHandle &handle) noexcept
Binds handle to the enabled driver D for which Connect(D::Connection&, Info const&,...
std::string UserName(ConnectionHandle const &connection)
The name of the user the connection is logged in as.
std::vector< std::int16_t > DescribeParameterTypes(StatementHandle const &statement, std::size_t count)
Describes the declared SQL type of each of the first count parameters.
std::expected< void, SqlErrorInfo > Close(ConnectionHandle &connection, CloseDiagnostic diagnostic) noexcept
Closes the connection: disconnects it, frees its driver resources and leaves connection empty,...
constexpr bool TranscodesNarrowText(SqlDriverId id) noexcept
Whether an enabled driver may pass narrow text through a client codepage, so that whether narrow text...
SqlResult Rollback(ConnectionHandle &connection) noexcept
Rolls back the open transaction.
bool AcceptsWideQueryText(ConnectionHandle const &connection) noexcept
Tells whether the connection's driver receives wide (UTF-16) query text unchanged.
SqlResult MoreResults(StatementHandle &statement) noexcept
Advances to the next pending result set.
bool TransactionsAllowed(ConnectionHandle const &connection) noexcept
Tells whether the data source supports transactions.
std::string DatabaseName(ConnectionHandle const &connection)
The name of the database in use.
CallOutcome CheckResult(StatementHandle const &statement, SqlResult result, std::source_location location)
The non-throwing, fault-seam-aware verdict on result.
bool IsAlive(ConnectionHandle const &connection) noexcept
Tells whether the driver still considers the connection alive.
SqlResult AllocateStatement(ConnectionHandle const &connection, StatementHandle &statement) noexcept
Allocates a statement of the connection's driver and binds statement to that driver.
std::variant< SqlConnectionDataSource, SqlConnectionString, SqliteConnectInfo > SqlConnectInfo
What a connection is opened from: an ODBC data source, an ODBC connection string, or a SQLite databas...
@ 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).
Verdict of a non-throwing checked driver call, carrying the diagnostic that justifies a failure verdi...
What a catalog call asks for: the ODBC catalog function and its arguments, in driver-neutral terms.
What a driver reports about a result column (see DescribeColumn).
Represents a SQL error as reported by the database driver.